Hi Andrea,

I have written the following code.

*html page : This html page will pass the uploaded file to the server
endpoint given below upon hitting the "Upload it" button.
*
<html>
<body>
        
JAX-RS Upload Form


        <form 
action="http://localhost:8080/IntegrationHub/hubServices/file/upload";
method="post" enctype="multipart/form-data">

           <p>
                Select a file : <input type="file" name="uploadedFile"/>
           </p>

           <input type="submit" value="Upload It" />
        </form>

</body>
</html>

*Camel Route :*

<route id="uploadDocRoute">
        <from uri="cxfrs://bean://uploadDoc" />
        <setExchangePattern pattern="InOut" />
        <camel:bean ref="RequestProcessor" 
method="UploadProcessing"></camel:bean>
        <to uri="cxfrs:bean:uploadDocClient" />
</route>

*Server Endpoint : html page will pass the uploaded file to this route. I am
able to receive the file till this point. This server Endpoint will pass the
file to the Client endpoint given below.*

<cxf:rsServer id="uploadDoc" address="/file"
        serviceClass="com.osb.ihub.ws.provider.endpoint.UploadFileService">
</cxf:rsServer>

*Service Class(Server Endpoint) :*

*Interface :*

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;

/**
 * @author siddharth.patil
 */
public interface UploadFileServiceInterface {

        @POST
        @Path("/upload")
        @Consumes("multipart/form-data")
        @Produces(MediaType.APPLICATION_JSON)
        public Response uploadFile(MultipartBody input);
}

*Java class that implements the interface:*

import javax.ws.rs.core.Response;
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;

public class UploadFileService implements UploadFileServiceInterface {

        public Response uploadFile(MultipartBody input) {
                return null;
        }
}

*Client Endpoint : I am not able to receive the file at this point.*

<cxf:rsClient id="uploadDocClient"
address="http://itlcpu703:8080/RestUploadFile/rest/file/upload";
        serviceClass="com.osb.ihub.ws.consumer.endpoint.UploadFileService"
        loggingFeatureEnabled="true">
</cxf:rsClient>

*Service class(client Endpoint) - Java class:*

import javax.ws.rs.core.Response;
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;

public class UploadFileService implements UploadFileServiceInterface {

        public Response uploadFile(MultipartBody input) {
                return null;
        }
}


Can you please suggest. I am not getting where I have made mistake.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Passing-a-file-through-camel-route-tp5790489p5790673.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to