You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "harbeer.kadian" <ha...@altair.com> on 2010/09/28 07:40:29 UTC

How to receive soap response attachment using Camel-Http component

Hi,

I am using Camel-Http component to talk with remote Webservices.
One of the operation present in the Webservice returns an attachment with
it.
The problem here is that the camel copies the whole response in the body
part of org.apache.camel.Message class.
The message class contains method like message.getAttachment(String id).
There should be some way by which you can get your webservice response in
the attachment section of Message class.

The current structure of body is as follows

--uuid:02620274-3a01-48c7-869e-ed45bdcc77f1
Content-Id:
<ro...@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary

<?xml version="1.0" ?><S:Envelope
xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:GetFileResponse
xmlns:ns2="http://www.example.org/Danger/"><xmlPayload><Include
xmlns="http://www.w3.org/2004/08/xop/include"
href="cid:9b35dfa0-a951-49f7-8cf7-167d4d7f864e@example.jaxws.sun.com"/></xmlPayload></ns2:GetFileResponse></S:Body></S:Envelope>

--uuid:02620274-3a01-48c7-869e-ed45bdcc77f1
Content-Id: <9b...@example.jaxws.sun.com>
Content-Type: application/xml; charset=UTF-8
Content-Transfer-Encoding: binary

<?xml version="1.0" encoding="UTF-8"?><name>test-name</name>
--uuid:02620274-3a01-48c7-869e-ed45bdcc77f1--

Here the last two lines represents the content inside the attachment.
Please tell what settings need to be done to get the attachment data in
message.getAttachment() method.

With Regards
Harbeer Kadian
-- 
View this message in context: http://camel.465427.n5.nabble.com/How-to-receive-soap-response-attachment-using-Camel-Http-component-tp2856274p2856274.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to receive soap response attachment using Camel-Http component

Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,

You cannot do this using a camel-http endpoint. The HTTP endpoint supports
all kinds of Markup Languages and does not care about SOAP, XML, HTML etc...

In order to get proper attachment support you need to use a CXF producer
endpoint, & when the response arrives, use a processor to get the attachment
from the Camel Message Exchange.  

For example

           from("direct:foo")
               .to("cxf:http://host:port/myservice?...)
               .process(new Processor() {
                    public void process(Exchange exchange) throws Exception
{
                          DataHandler dr =
exchange.getOut().getAttachment(photoId);
                          if
(dr.getContentType().equalsIgnoreCase("application/octet-stream") {
                             LOG.info("Got a GIF/JPEG");
                          }
                    }
                 });

Hope this helps.

Cheers,

Ashwin...

-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com
http://opensourceknowledge.blogspot.com 
---------------------------------------------------------
-- 
View this message in context: http://camel.465427.n5.nabble.com/How-to-receive-soap-response-attachment-using-Camel-Http-component-tp2856274p3073555.html
Sent from the Camel - Users mailing list archive at Nabble.com.