Thanks Guillaume,
I have tried using the HttpComponent, but it threw an exception in the
DeliveryChannel and ReceiverComponent. My client code is the following:
File f = new File("some_file.txt");
PostMethod filePost = new
PostMethod("http://localhost:8192/Service/");
Part[] parts = { new StringPart("param_name", "value"),
new FilePart(f.getName(), f) };
filePost.setRequestEntity(
new MultipartRequestEntity(parts, filePost.getParams()) );
HttpClient client = new HttpClient();
int status = client.executeMethod(filePost);
filePost.releaseConnection();
and my XmlBeans configuration file is the following
<sm:activationSpec>
<sm:component>
<http:component>
<http:endpoints>
<http:endpoint service="test:MyConsumerService"
endpoint="myConsumer"
role="consumer"
locationURI="http://localhost:8192/Service/"
defaultMep="http://www.w3.org/2004/08/wsdl/in-only" />
</http:endpoints>
</http:component>
</sm:component>
</sm:activationSpec>
<sm:activationSpec service="test:MyConsumerService"
endpoint="myConsumer">
<sm:component>
<bean class="org.apache.servicemix.tck.ReceiverComponent" />
</sm:component>
</sm:activationSpec>
and I get the following exceptions
[edThreadPool0-1] DEBUG DeliveryChannel - Unable to
display message
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:123)
at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toDOMSourceFromStream(SourceTransformer.java:221)
at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toDOMSource(SourceTransformer.java:136)
at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toDOMNode(SourceTransformer.java:275)
at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.traceMessageExchange(DeliveryChannelImpl.java:297)
at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(DeliveryChannelImpl.java:388)
at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.send(DeliveryChannelImpl.java:490)
at
org.apache.servicemix.common.BaseLifeCycle.sendConsumerExchange(BaseLifeCycle.java:389)
at
org.apache.servicemix.http.processors.ConsumerProcessor.process(ConsumerProcessor.java:131)
at
org.apache.servicemix.http.HttpBridgeServlet.doPost(HttpBridgeServlet.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:615)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
SEVERE: [EMAIL PROTECTED] got
error processing [EMAIL PROTECTED]
javax.jbi.messaging.MessagingException: org.xml.sax.SAXParseException:
Content is not allowed in prolog.
at
org.apache.servicemix.components.util.CopyTransformer.transform(CopyTransformer.java:80)
at
org.apache.servicemix.tck.ReceiverComponent.onMessageExchange(ReceiverComponent.java:47)
at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:636)
at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:171)
at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:221)
at
org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291)
at
EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:264)
at
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:123)
at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toDOMSourceFromStream(SourceTransformer.java:221)
at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toDOMSource(SourceTransformer.java:136)
at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toDOMNode(SourceTransformer.java:275)
at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toDOMNode(SourceTransformer.java:302)
at
org.apache.servicemix.jbi.jaxp.SourceTransformer.toDOMSource(SourceTransformer.java:144)
at
org.apache.servicemix.components.util.CopyTransformer.transform(CopyTransformer.java:68)
... 7 more
Thanks,
Stefan
Guillaume Nodet wrote:
The servicemix-http component handles MIME attachments.
You should give it a try.
Cheers,
Guillaume Nodet
On 3/22/06, Stefan Klinger <[EMAIL PROTECTED]> wrote:
Hello all,
I am trying to include a file upload facility using http within my
project. Unfortunately, my file is not an xml document, so it should be
treated as an attachment. If I am correct, the HttpMarshaler only
accepts xml documents which are set to the message content. Would there
be a way to accept non-xml files and set them as message attachments
(similar to the SaajMarshaler)? Or is there another, more elegant way of
doing this?
Thanks,
Stefan