Using Apache Camel, how do I untie my deserialized object that enters through the CXF endpoint?

I have a very simple camel route. It starts at the CXF endpoint, displayed as a web service. Then I want to convert it to xml and call the method on bean.

I am currently getting a special CXF object after calling a web service. How to take my serialized object from CXF MessageList and use it in the future?

My route:

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

Serialized XML 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 look something 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> 
+4
source share
2 answers

I found him. I just had to use this.

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

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

I assume that you are using CXF wsdl2java to automatically create model objects? If so, you can see the generated source code that should have @JAXB annotations

0
source

Source: https://habr.com/ru/post/1306831/


All Articles