I am using apache-servicemix-4.5.3 with camel routing engine. I want to pass uploaded file to another web application deployed on tomcat 8 with Spring 3 MVC. In simple example:
I have:
<cxf:rsServer id="server" address="http://0.0.0.0:9001/">
<cxf:serviceBeans>
<ref bean="SampleService" />
</cxf:serviceBeans>
</cxf:rsServer>
<route>
<from uri="cxfrs://bean://server" />
<removeHeaders pattern="CamelHttp*"/>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<to uri="ref:someEndpoint" />
</route>
Service:
@Path("/example")
public interface InvoiceService {
@POST
@Path("/upload")
@Consumes({MediaType.MULTIPART_FORM_DATA})
@Produces(MediaType.APPLICATION_JSON)
Result2<Integer> upload(Attachment input) ;
On endpoint there is spring REST controller, let it be:
@Controller
@RequestMapping(value="/")
public class SomeController{
@RequestMapping(method = RequestMethod.POST, value = "/upload")
@ResponseBody
public Result upload(MultipartHttpServletRequest req){
//...
}
I have no problem with uploading file to one of the servers, I have problem with forwarding file from ESB (apache-servicemix) to web app deployed on Tomcat.
Update
The exact problem is exception occuring probably while sending request to endpoint:
No body available of type: java.io.InputStream but has value: [org.apache.cxf.jaxrs.ext.multipart.Attachment@c421de12] of type: org.apache.cxf.message.MessageContentsList on: Message: [org.apache.cxf.jaxrs.ext.multipart.Attachment@c421de12]. Caused by: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: java.io.InputStream with value [org.apache.cxf.jaxrs.ext.multipart.Attachment@c421de12]