I don't think http component support the multipart/form-data out of box.
If you still want to do it, you can consider to add a processor to create the request entity like this

from("file:inbox?noop=false").process(new Processor() {
       // setup the request entity in this processor
       public void process(Exchange exchange) throws Exception {
          Message in = exchange.getIn();
          File file = in.getBody();
          Part[] parts = {
            new FilePart(file.getName(), file)
          }
          HttpMethodParams params = new HttpMethodParams();
params.setParameter(HttpMethodParams.USE_EXPECT_CONTINUE,true);
MultipartRequestEntity reqEntity = new MultipartRequestEntity(parts,params);
          exchange.getOut().setBody(reqEntity);
        };

   }).to("http://localhost:8080/myServer/";);


On Fri Oct 14 18:39:24 2011, Claus Ibsen wrote:
Hi

Are you really using Camel 2.0.0 ? This is a very old release.

The camel-http component have been improved so it detects if you
pickup files, and upload that using the File support from the Http
Client framework.

So if possible I suggest to try to consider upgrading Camel.


On Thu, Oct 13, 2011 at 3:58 PM, Mohammad Shadab Ali
<mohammad....@headstrong.com>  wrote:
Hi,

I tried to upload the files using apache commons httpclient and FileUpload api 
as multipart POSTs and it was successful. But the same thing when I tried using 
camel routes I am getting exception at both sides server and client.
I am getting the following exceptions:

1.      At client side :

SEVERE: HTTP operation failed with statusCode: 500, status: HTTP/1.1 500 
Internal Server Error
org.apache.camel.component.http.HttpOperationFailedException: HTTP operation 
failed with statusCode: 500, status: HTTP/1.1 500 Internal Server Error
        at 
org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:141)
        at 
org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:89)
        at 
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:81)
        at 
org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:79)
        at 
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:141)
        at 
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:78)
        at 
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:61)
        at 
org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:186)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
Oct 13, 2011 5:50:26 PM org.apache.camel.component.file.GenericFileOnCompletion 
processStrategyRollback
WARNING: Rollback file strategy: 
org.apache.camel.component.file.strategy.GenericFileNoOpProcessStrategy@1632847 
for file: GenericFile[academy.xml]
Oct 13, 2011 5:50:26 PM org.apache.camel.processor.Logger log



2.      At server side :

SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.commons.fileupload.FileUploadException: the request was rejected 
because no multipart boundary was found
        at 
org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:327)
        at 
org.apache.jsp.ProcessFileUpload_jsp._jspService(ProcessFileUpload_jsp.java:78)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
        at 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)



3.      I am using the below camel route to upload the file.


        from("file:inbox?noop=true").setHeader(Exchange.HTTP_METHOD, 
constant(org.apache.camel.component.http.HttpMethods.POST))
                                        .setHeader(Exchange.CONTENT_TYPE, 
constant("multipart/form-data"))                                                          
                                                                                            
.to("http://10.200.41.29:8082/displaytag-examples-1.2/ProcessFileUpload.jsp";);

Has anyone else seen this or have any ideas on how to get around this issue?


Thank you.

Regards,
Shadab


















-----Original Message-----
From: Willem Jiang [mailto:willem.ji...@gmail.com]
Sent: Tuesday, October 11, 2011 12:28 PM
To: users@camel.apache.org
Subject: Re: Need help with Camel http producer

Did you check the service log which works listen to 
"http://localhost:8080/myServer/"; ?

On Tue Oct 11 14:40:46 2011, Mohammad Shadab Ali wrote:
Hi,


1.       I am new with Camel. I am trying to create route as to process file 
from a file component and pass on to a http tomcat server through http 
producer, but I am not able to upload the file to the server.

2.       I have created the route as follows

from("file:inbox?noop=false").to("http://localhost:8080/myServer/";);

I have also tried using my I.P address in place of localhost


3.       I am not getting any compilation error nor at runtime and the file is 
getting processed from inbox folder, but I am not able to receive the file in 
myServer directory.

4.       Camel version I am using is 2.0.0 .


Thanks&    regards,
Shadab


________________________________
***The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review,retransmission,dissemination or other
use of, or taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited.
If you received this in error, please contact the sender and delete
the material from any computer.***




--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang


***The information transmitted is intended only for the person or entity to 
which it is addressed and may contain confidential and/or privileged material. 
Any review,retransmission,dissemination or other use of, or taking of any 
action in reliance upon, this information by persons or entities other than the 
intended recipient is prohibited. If you received this in error, please contact 
the sender and delete the material from any computer.***







--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Reply via email to