【发布时间】:2016-01-26 11:58:22
【问题描述】:
需要从 Web 服务获取列表或数组(cxf,我使用蓝图)。 WSLD、代码和堆栈跟踪如下。我尝试使用 Object[] 但得到类似的错误。
如何修复此代码?
public class Bean implements Service{
public Pojo[] get() {
Pojo p1 = new Pojo();
Pojo p2 = new Pojo();
p1.setName("1");
p1.setAge("11");
p2.setName("2");
p2.setAge("22");
return new Pojo[]{p1,p2};
}
}
pojo:
@XmlRootElement
public class Pojo {
private String name;
private String age;
//get's, setter's
}
蓝图:
<cxf:cxfEndpoint id="endPoint" address="http://localhost:9292/test" serviceClass="one.Service" />
<bean id="bean" class="one.Bean" />
<camelContext id="blueprintContext" trace="false" xmlns="http://camel.apache.org/schema/blueprint">
<route id="cxfRoute">
<from uri="cxf:bean:endPoint"/>
<log message="${header.operationName}"/>
<recipientList>
<simple>direct:${header.operationName}</simple>
</recipientList>
</route>
<route id="get">
<from uri="direct:get"/>
<bean method="get" ref="bean"/>
</route>
</camelContext>
在骆驼:运行并发送请求之后,我得到了这个堆栈跟踪
java.lang.IllegalArgumentException: Part {http://one/}return should be of type [Lone.Pojo;, not one.Pojo
at org.apache.cxf.jaxb.io.DataWriterImpl.checkPart(DataWriterImpl.java:273)
at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:205)
at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:114)
at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:242)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:355)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:319)
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1088)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1024)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:193)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handleAsync(Server.java:410)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:519)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:745)
【问题讨论】:
-
你可以在这里发布 WSDL 吗?
标签: java web-services soap apache-camel cxf