Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 795
ScArcher2 Avatar asked Feb 28 '23 05:02

ScArcher2


1 Answers

I found it. I just had to use this.

<camel:convertBodyTo type="com.whatever.Person"/>
like image 93
ScArcher2 Avatar answered Mar 05 '23 15:03

ScArcher2