开发者

Using Apache Camel how do I unmarshal my deserialized object that comes in through a CXF Endpoint?

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>


I found it. I just had to use this.

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜