camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raul Kripalani <r...@evosent.com>
Subject Re: CXF Bean, MultiPart -> Couldn't find MIME boundary
Date Thu, 18 Apr 2013 23:00:12 GMT
You'd drop Jetty and use a Camel CXFRS consumer endpoint instead. Its usage
is documented in http://camel.apache.org/cxfrs.html. Please take a look
there first.

Worse comes to worst, if this approach doesn't work for you, given your
constraints with such old versions, I'd propose to switch back to Jetty and
use Apache Commons FileUpload library to parse the incoming InputStream,
inside a Camel processor.

Regards,

*Raúl Kripalani*
Enterprise Architect, Open Source Integration specialist, Program
Manager | Apache
Camel Committer
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Thu, Apr 18, 2013 at 10:03 PM, Calvert, Zach (Zach)** CTR ** <
zcalvert@motive.com> wrote:

> I think I misread your reply on my first round.
>
> If I pulled the SimpleCxfRsBinding into 2.6.0, not the whole 2.11 jar,
> what would my camel route look like to make use of it including the port?
>  Would I still be using jetty or configuring a cxfRsBinding in XML/cfg?
>
>
>
> Thanks again!
>
> -----Original Message-----
> From: Raul Kripalani [mailto:raul@evosent.com]
> Sent: Thursday, April 18, 2013 3:42 PM
> To: users@camel.apache.org
> Subject: Re: CXF Bean, MultiPart -> Couldn't find MIME boundary
>
> Why don't you use the CXFRS endpoint directly, instead of bridging over
> through Jetty? Something's probably going haywire with the combination of
> Jetty, CXF bean and Multiparts...
>
> Note there's a new SimpleCxfRsBinding in 2.11 [1], which you can use in
> older versions by copying the class into your project, and referencing it
> as a standard binding like this:
>
> from("cxfrs:bean:rsServer?binding=#cxfRsBinding")...
> Then annotate your JAX-RS method with:
>
> @POST
> @Consumes("multipart/form-data")
> public String postImage4(@FormParam("firstname") String firstname,
> @Multipart(name="image", type="application/octet-stream") Attachment file))
> {
>    return null;
> }
>
> The firstname should be available in a header "firstname", while the file
> should be placed in an IN message attachment called "image".
>
> Note that the code of the JAX-RS method is not really used, as the
> response will be the output of the Camel route itself.
>
> More info here [2].
>
> [1]
>
> https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/SimpleCxfRsBinding.java
> [2]
>
> http://camel.apache.org/cxfrs.html#CXFRS-ConsumingaRESTRequestSimpleBindingStyle
>
> Regards,
>
> *Raúl Kripalani*
> Enterprise Architect, Open Source Integration specialist, Program Manager
> | Apache Camel Committer http://about.me/raulkripalani |
> http://www.linkedin.com/in/raulkripalani
> http://blog.raulkr.net | twitter: @raulvk
>
> On Thu, Apr 18, 2013 at 9:28 PM, Calvert, Zach (Zach)** CTR ** <
> zcalvert@motive.com> wrote:
>
> > Hello Christian,
> > Thank you for your help.  Unfortunately that didn't change the outcome.
> >  The AttachmentDeserializer class's "readTillFirstBoundary" still
> > exits upon the first read due to a -1 from the first read of the IO
> > stream.  I have tried FireFox, Chrome, and IE.  Any other ideas?
> > Could it be my HTML form?
> >
> > <html>
> >         <body>
> >                 <form enctype='multipart/form-data' method='post'
> > action='/submit'>
> >                         <INPUT type='text' id='firstname'>
> >                         <BR>
> >                         <input type='file' name='image'>
> >                         <br>
> >                         <input type='submit' value='Send'>
> >                 </form>
> >         </body>
> > </html>
> >
> > If not, could I be doing something wrong with my CXF function
> > receiving the message?
> >
> > I've tried both of the following:
> >     @POST
> >     @Path("submit")
> >     @Produces("text/html")
> >     public String postImage4(Message message) {
> >         return "hello " + message;
> >     }
> >
> >     @POST
> >     @Path("submit")
> >     @Produces("text/html")
> >     public String postImage4(List<Attachment> atts) {
> >         return "hello " + atts;
> >     }
> >
> > I've also confirmed I can get to the request by returning the html
> > form from a
> >
> >     @GET
> >     @Path("submit")
> >     @Produces("text/html")
> >     public String postImage4() {
> >         return "<html><body><form enctype='multipart/form-data'
> > method='post' action='/submit'><INPUT type='text'
> > id='firstname'><BR><input type='file' name='image'> <br><input
> type='submit'
> > value='Send'></form></body></html>";
> >     }
> >
> > I don't think it is pathing since the error is occurring in an
> > interceptor but I'll entertain any ideas at this point.
> >
> >
> >
> > Thanks,
> > Zach Calvert
> >
> >
> >
> >
> >
> >
> > -----Original Message-----
> > From: Christian Müller [mailto:christian.mueller@gmail.com]
> > Sent: Wednesday, April 17, 2013 4:58 PM
> > To: users@camel.apache.org
> > Subject: Re: CXF Bean, MultiPart -> Couldn't find MIME boundary
> >
> > Can you enable stream caching and try it again.
> >
> > http://camel.apache.org/stream-caching.html
> >
> > Best,
> > Christian
> >
> > Sent from a mobile device
> > Am 17.04.2013 23:53 schrieb "Calvert, Zach (Zach)** CTR **" <
> > zcalvert@motive.com>:
> >
> > > I'm having trouble submitting a multi-part form to a CXF endpoint.
> > > My route looks like:
> > >         <camel:route id="submitform">
> > >             <camel:from uri="jetty:
> > > https://0.0.0.0:9005/submit/?matchOnUriPrefix=true"/>
> > >             <camel:log message="Request received"
> loggingLevel="DEBUG"/>
> > >             <camel:to uri="cxfbean:consumerList"/>
> > >         </camel:route>
> > > Where the list is a util list of 1 endpoint consuming a POST method.
> > > The HTML form code is retrieved from the same path using a GET,
> > resulting in:
> > >
> > > <html>
> > >     <body>
> > >         <form enctype='multipart/form-data' method='post'
> > action='/submit'>
> > >             <INPUT type='text' id='firstname'>
> > >             <BR>
> > >             <input type='file' name='image'>
> > >             <BR>
> > >             <input type='submit' value='Send'>
> > >         </form>
> > >     </body>
> > > </html>
> > >
> > > Submitting a post triggers this in the logs:
> > > 2013-04-17 15:55:40,900 | WARN  | qtp11314826-356  |
> > > WebApplicationExceptionMapper    |  -  -  | WebApplicationException has
> > > been caught : Couldn't find MIME boundary:
> > > -----------------------------173102388111750
> > >
> > > I walked the code to
> > > org.apache.cxf.attachment.AttachmentDeserializer
> > > Where it obtains the "InputStream" content body using:
> > > ...
> > >             boundary = boundaryString.getBytes("utf-8");
> > >
> > >             stream = new
> > > PushbackInputStream(message.getContent(InputStream.class),
> > >                                              pbAmount); ...
> > >
> > > The resulting InputStream from the CXF Message, while non-null,
> > > always returns -1 at the first read.  In other words, this
> > > InputStream is empty 100% of the time.  I've verified using
> > > different browsers that the content is submitted, and the MIME
> > > boundary is populated in the content.  What is going on with the
> > > input stream?  Have I configured my CXF endpoint incorrectly in some
> > > way, or am I missing a configuration
> > detail in the form?
> > >
> > > Any and all help is greatly appreciated!
> > >
> > >
> > > Thank you,
> > > Zach Calvert
> > >
> > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message