使用 Apache Camel 如何解组通过 CXF 端点传入的反序列化对象?
我有一条非常简单的骆驼路线。它从公开为 Web 服务的 CXF 端点开始。 然后我想将其转换为 xml 并调用 bean 上的方法。
目前,我在 Web 服务调用后获得了 CXF 特定对象。 如何从 CXF MessageList 中取出序列化对象并继续使用它?
我的路线:
<camel:route>
<camel:from uri="cxf:bean:helloEndpoint" />
<camel:marshal ref="xstream-utf8" />
<camel:to uri="bean:hello?method=hello"/>
</camel:route>
XML 序列化消息:
<?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>
我希望 XML 更像这样:
<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 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了。我只得用这个。
I found it. I just had to use this.
您还可以使用 JAXB 数据格式,我认为 CXF 开箱即用地支持这种格式。
我假设您已经使用 CXF wsdl2java 自动生成模型对象?如果是这样,您可以查看生成的源代码,其中应该有 @JAXB 注释
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