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 ** <
[email protected]> 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:[email protected]]
> Sent: Wednesday, April 17, 2013 4:58 PM
> To: [email protected]
> 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 **" <
> [email protected]>:
>
> > 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
> >
> >
> >
>