我有一条简单的路线,如下所示:
Debug 'py.test in...'
cxf配置也非常简单:
<route handleFault="true" streamCache="true" id="routeA">
<from uri="cxfrs://bean://simpleCxf" />
<log message="The message body contains ${body}"/>
<to uri="direct-vm:RouteB" />
</route>
<route handleFault="true" streamCache="true" id="routeB">
<from uri="direct-vm:RouteB" />
<bean ref="requestValidator" method="validateRequest" />
<log message="The input message ${body}" />
<bean ref="dbClient" method="queryDatabase" />
</route>
这条简单的路线因以下异常而失败
<cxf:rsServer id="simpleCxf" address="/test"
loggingFeatureEnabled="true"
serviceClass="com.gogol.test.TestResource">
</cxf:rsServer>
这是消息历史记录,表明它在No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.apache.camel.Exchange with value [com.gogol.test.resource.SimpleObject@773736ca]
<bean ref="requestValidator" method="validateRequest" />
我认为问题在于Camel正在尝试将cxf生成的主体转换为Exchange对象。因为requestValidator类有一个签名为:
的方法Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)
[routeA] [routeA] [direct-vm://routeA ] [6]
[routeB] [log12 ] [log ] [2]
[routeB] [to9 ] [direct-vm:routeA ] [4]
[routeA] [bean26] [bean[ref:requestValidator method: validateRequest]] [2]
但理想情况下,cxf生成的消息应设置为Exchange内部的主体。我是否正确,如果没有,那可能是上述例外的原因?
编辑:
我使用的是CXF 3.0.4版本.redhat-621084 和CAMEL版本2.15.1.redhat-621084
public void validateRequest(Exchange exchange) thows SomeException.
答案 0 :(得分:0)
我对camel xml dsl没有肯定如何正确格式化,但你总是可以明确告诉camel进行类型转换。您可以使用convertBodyTo调用来强制进行类型转换来测试您的理论。
from("myEndpoint")
.log("This is my previous object")
.convertBodyTo(TestResource.class)
.log("This is my object after a camel type conversion");