You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by xiangqiuzhao <xi...@gmail.com> on 2011/08/21 15:22:04 UTC

send cxf message by MESSAGE format but can't get response

i had send the request message to web services, and the services can execute
successful.

but the camel message's out body is HttpInputStream, and i read from the
stream by 

        byte[] b = new byte[4096];
        int len = ((InputStream)exchange.getOut().getBody()).read(b);

output string is "<soap:Envelope xmlns:soap="h", why only 28 bytes readed? 
it should be:

<soap:Envelope>
   <soap:Body xmlns:ns1="http://www.wstest.sunyard.com/IWSTestService/">
      <ns2:helloServiceResponse
xmlns:ns2="http://www.wstest.sunyard.com/IWSTestService/">
         <value>hello ttt</value>
      </ns2:helloServiceResponse>
   </soap:Body>
</soap:Envelope>

and my request is :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:iws="http://www.wstest.sunyard.com/IWSTestService/">
   <soapenv:Header/>
   <soapenv:Body>
      <iws:helloServiceRequest>
         <name>ttt</name>
      </iws:helloServiceRequest>
   </soapenv:Body>
</soapenv:Envelope>


--
View this message in context: http://camel.465427.n5.nabble.com/send-cxf-message-by-MESSAGE-format-but-can-t-get-response-tp4720445p4720445.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: send cxf message by MESSAGE format but can't get response

Posted by Christian Müller <ch...@gmail.com>.
Did you already looked into our unit tests [1]? It's a good source to get
answers...
Another good source are our examples [2]. We developed 5 examples relatet to
CXF.

Hope you get the answers you are looking for...

[1]
https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/
[2] https://svn.apache.org/repos/asf/camel/trunk/examples/

Best,
Christian

Re: send cxf message by MESSAGE format but can't get response

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

When you read the stream, you can not be sure that you read all the 
bytes of message once.
You need to use a while to check if you can still read the bytes from 
stream.

Or you can leverage the Camel type convertor to turn the input stream 
into a String just like this

String result = exchange.getOut().getBody(String.class);

On 8/21/11 9:22 PM, xiangqiuzhao wrote:
> i had send the request message to web services, and the services can execute
> successful.
>
> but the camel message's out body is HttpInputStream, and i read from the
> stream by
>
>          byte[] b = new byte[4096];
>          int len = ((InputStream)exchange.getOut().getBody()).read(b);
>
> output string is "<soap:Envelope xmlns:soap="h", why only 28 bytes readed?
> it should be:
>
> <soap:Envelope>
>     <soap:Body xmlns:ns1="http://www.wstest.sunyard.com/IWSTestService/">
>        <ns2:helloServiceResponse
> xmlns:ns2="http://www.wstest.sunyard.com/IWSTestService/">
>           <value>hello ttt</value>
>        </ns2:helloServiceResponse>
>     </soap:Body>
> </soap:Envelope>
>
> and my request is :
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:iws="http://www.wstest.sunyard.com/IWSTestService/">
>     <soapenv:Header/>
>     <soapenv:Body>
>        <iws:helloServiceRequest>
>           <name>ttt</name>
>        </iws:helloServiceRequest>
>     </soapenv:Body>
> </soapenv:Envelope>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/send-cxf-message-by-MESSAGE-format-but-can-t-get-response-tp4720445p4720445.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang