views:

305

answers:

2

I have a very simple camel route. It starts with a CXF Endpoint exposed as a web service. I then want to convert it to xml and call a method on a bean.

Currently i'm getting a CXF specific object after the web service call. How do I take my serialized object out of the CXF MessageList and use it going forward?

My Route:

<camel:route>
   <camel:from uri="cxf:bean:helloEndpoint" />
   <camel:marshal ref="xstream-utf8" />
   <camel:to uri="bean:hello?method=hello"/>
</camel:route>

The XML Serialized Message:

<?xml version='1.0' encoding='UTF-8'?>
<org.apache.cxf.message.MessageContentsList serialization="custom">
   <unserializable-parents />
   <list>
      <default>
         <size>1</size>
      </default>
      <int>6</int>
      <com.whatever.Person>
         <firstName>Joe</firstName>
         <middleName></middleName>
         <lastName>Buddah</lastName>
         <dateOfBirth>2010-04-13 12:09:00.137 CDT</dateOfBirth>
      </com.whatever.Person>
   </list>
</org.apache.cxf.message.MessageContentsList>

I would expect the XML to be more like this:

<com.whatever.Person>
   <firstName>Joe</firstName>
   <middleName></middleName>
   <lastName>Buddah</lastName>
   <dateOfBirth>2010-04-13 12:09:00.137 CDT</dateOfBirth>
</com.whatever.Person>
A: 

I found it. I just had to use this.

<camel:convertBodyTo type="com.whatever.Person"/>
ScArcher2
A: 

You can also use JAXB data format, which I think CXF supports out of the box.

I assume you have use CXF wsdl2java to have the model objects auto generated? If so you can look at the generated source code which should have @ JAXB annotations

Claus Ibsen
I'm actually exposing a web service rather than consuming one. I'm also not using wsdl2java, but thanks for the information. I'm sure it will come in handy in the future!
ScArcher2