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