使用 Apache Camel 如何解组通过 CXF 端点传入的反序列化对象?

发布于 2024-08-29 02:50:32 字数 1365 浏览 1 评论 0原文

我有一条非常简单的骆驼路线。它从公开为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

十六岁半 2024-09-05 02:50:32

我找到了。我只得用这个。

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

I found it. I just had to use this.

<camel:convertBodyTo type="com.whatever.Person"/>
蓝色星空 2024-09-05 02:50:32

您还可以使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文