需要從Web服務(cxf和我使用藍圖)獲取列表或數組。 WSLD,代碼和堆棧跟蹤如下。我試圖使用Object [],但得到類似的錯誤。 來自soap web服務(cxf)的返回列表或數組
如何修復此代碼?
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? –