【发布时间】:2014-01-02 22:03:38
【问题描述】:
我有一个骆驼路线公开为 CXF 网络服务。这是一个自下而上的 Web 服务,其操作如下:
List<Book> getBooks();
CXF端点定义为:
<cxf:cxfEndpoint id="bookService"
address="http://localhost:9045/bookservice"
serviceClass="org.test.cxfws.service.BookDBService">
</cxf:cxfEndpoint>
该操作查询书籍列表并将其返回给调用者。骆驼路线如下所示:
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="cxf:bean:bookService"/>
<choice>
<when>
<simple>${header.operationName} == 'getBooks'</simple>
<to uri="bean:wsImplBean?method=getBooks"/>
</when>
<to uri="log:outboundSoapResponse"/>
<choice>
</route>
</camel:camelContext>
运行路线后,我得到以下异常:
org.apache.cxf.interceptor.Fault:org.test.cxfws.service.Book 无法转换为 java.util.List 在 org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:117) 在 org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272) 在 org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77) 在 org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272) ...
原因:java.lang.ClassCastException: org.test.cxfws.service.Book 无法转换为 java.util.List 在 org.test.cxfws.service.GetBooksResponse_WrapperTypeHelper1.createWrapperObject(未知来源) 在 org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor.handleMessage(WrapperClassOutInterceptor.java:101)
我可以看到,来自 bean wsImpBean 的 getBooks 方法被执行,结果在路由内 choice 块的末尾返回:
[qtp1653072092-14] outboundSoapResponse INFO Exchange[ExchangePattern: InOut, BodyType: java.util.ArrayList, Body: [org.test.cxfws.service.Book@63f1858b, org.test.cxfws.service.Book@5769bf0 , org.test.cxfws.service.Book@2df7ac5d, org.test.cxfws.service.Book@5f55253e, org.test.cxfws.service.Book@4f003a57]]
谁能帮我理解为什么 ClassCastException。
谢谢。
【问题讨论】:
标签: cxf apache-camel