简体   繁体   中英

apache camel cxf soap

I am developing a web service (soap) using apache camel cxf I encountered this error.

java.lang.IllegalArgumentException: Part { http://blueprint.camel.ngt.tn/ }return should be of type [Ltn.ngt.camel.blueprint.WB_subscriptions;, not tn.ngt.camel.blueprint.WB_subscriptions at org.apache.cxf.jaxb.io.DataWriterImpl.checkPart(DataWriterImpl.java:292) at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:220) at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:122) at org.apache.cxf.wsdl.interceptors.BareOutInterceptor.handleMessage(BareOutInterceptor.java:69) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:83) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) at org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:277) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObs erver.java:78) at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:251) at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:261) at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70) 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 or g.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:696) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53) 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(Unknown Source)

is there anyone who can help me solve this problem, here is my source code

blueprint

 <cxf:cxfEndpoint  address="http://localhost:9191/cxf/Subsriptions" id="claimEndpoint" serviceClass="tn.ngt.camel.blueprint.WbSubscriptionService"/>

 <camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="GetWb_Subscription">
     <from uri="cxf:bean:claimEndpoint"/>
   <!--  <from uri="timer:foo?period=10000"/>-->
    <to uri="sql:select * from WB_SUBSCRIPTIONS?dataSource=dataSource"/>
    <to uri="bean:tn.ngt.camel.blueprint.Transformer?method=ToList(Exchange)"/>  
     <to uri="bean:tn.ngt.camel.blueprint.Transformer?method=getSubscriptions"/>
  <log message="The message contains ${body}"/>
</route>

WbSubscriptionService

    public interface WbSubscriptionService {
    public List<WB_subscriptions> getSubscriptions();

}

Transformer

public class Transformer {
public static List<WB_subscriptions> subscription= new ArrayList<WB_subscriptions>();
@SuppressWarnings("unchecked")
public List<WB_subscriptions> ToList(Exchange exchange) throws NumberFormatException, ParseException{
    List<?> messages= exchange.getIn().getBody(List.class);
    List<WB_subscriptions>LstWb_Sub= new ArrayList<WB_subscriptions>();
    for(int i=0;i<messages.size();i++){
        Map<String,Object> row = (Map<String,Object>) messages.get(i);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
        WB_subscriptions wb= new WB_subscriptions( Integer.parseInt(row.get("CUST_ACCOUNT").toString()),
                Integer.parseInt(row.get("PACKAGE_ID").toString()),Integer.parseInt(row.get("CUST_MOBILE").toString()) , formatter.parse(row.get("DATE_CREATION").toString()));
                System.out.println(wb.getCust_mobile());
                LstWb_Sub.add(wb);  

    }
    subscription=LstWb_Sub;
    System.out.println("List 1 "+subscription);
    return LstWb_Sub;

}
public List<WB_subscriptions> getSubscriptions() throws Exception{
    System.out.println("bonjour "+subscription);
    return subscription;
}

thanks in advance: D

Well the error message simply says that the return type must be a collection of WB_subscriptions not a single WB_subscriptions .

You can read the first part of the error message as follows:

  • [ => Array of ...
  • L...; => between L and ; is a fully classified class name
  • tn.ngt.camel.blueprint.WB_subscriptions => your class name

However, there are some issues when returning a Java collection from the webservice (for example this one ).

Therefore try to either return an Array of WB_subscriptions or wrap the List in a Bean and return the single Bean that contains the list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM