I just ran a simple test by printing out the result of exchange.getIn().getBody(String.class) in the CxfConsumerPayloadTest.java on the trunk (Camel 2.3-SNAPSHOT), I can see the message body was printed out rightly.

Which version of Camel are you using ?

Willem

Willem Jiang wrote:
Hi,

When you use exchange.getIn().getBody(String.class) to get the message,
camel will try to find a right converter to turn PayLoad (the actual object stored in the message body) into String.
It looks like there is not a converter to do this job, so you got null.
If I remember right, a StringConverter should be use in this case, I don't know why it doesn't work for you. If you use exchange.getIn().getBody() , you should get the PayLoad object. You can find more detail example here[1]

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

Willem

Olivier Roger wrote:
Hello Camel,

I am experimenting a strange issue when using CXF inbound endpoint with
PAYLOAD dataformat option (no problem in MESSAGE mode).

First I declare a CXF endpoint:

    <cxf:cxfEndpoint id="F1" address="http://localhost:10101/F1";
serviceClass="CXFUseCase"> <!-- Interface with one method -->
        <cxf:dataBinding>
            <bean class="org.apache.cxf.xmlbeans.XmlBeansDataBinding" />
        </cxf:dataBinding>
        <cxf:properties>
            <entry key="dataFormat" value="PAYLOAD"/>
        </cxf:properties>
    </cxf:cxfEndpoint>

Then, in my route I use it:

        <route>
            <from uri="cxf:bean:F1" />
            <bean ref="inspect" />

When I debug in the inspect bean the Exchange object does not contain any
value.
However, setting a response value works correctly.

    public void process(final Exchange exchange){
        String msg = exchange.getIn().getBody(String.class);
        System.out.println(msg); // is null
exchange.getOut().setBody(createResponse(), PersonDocument.class); //
is ok
    }

I read the documentation on the website but found it quite not clear. Am I
doing something wrong?

Thanks in advance,

Olivier



Reply via email to