Apache Camel 牌CXF香皂

xpcnnkqh  于 2022-11-07  发布在  Apache
关注(0)|答案(1)|浏览(135)

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(ChainInitiationObserver.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 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: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

ezykj2lf

ezykj2lf1#

错误消息只是简单地说,返回类型必须是**WB_subscriptions的集合,而不是单个WB_subscriptions
您可以阅读错误消息的第一部分,如下所示:

  • [ =〉数组...
  • L...; =〉介于L;之间,是完全分类的类名
  • tn.ngt.camel.blueprint.WB_subscriptions =〉您的类名

但是,从Web服务返回Java集合时会出现一些问题(例如this one)。
因此,请尝试返回WB_subscriptions的Array,或者将List Package 在Bean中并返回包含该列表的单个Bean。

相关问题