我正在使用apache camel cxf开发一个Web服务(肥皂),我遇到了这个错误。
Java . lang . illegalargumentexception:Part { http://blue print . camel . ngt . TN/}返回的类型应为[ltn . ngt . camel . blue print . WB _ subscriptions;,而不是org . Apache . cxf . JAXB . io . datawriterimpl . check part(datawriterimpl . Java:292)上的TN . ngt . camel . blue print . WB _ subscriptions。jettypdestination . do service(jettypdestination . Java:261)位于org . Apache . cxf . transport . http _ jetty。jettyhttphandler . handle(jettyhttphandler . Java:70)在org . eclipse . jetty . server . handler . context handler . do handle(context handler . Java:1088)在org . eclipse . jetty . server . do scope(context handler . Java:1024)在org . eclipse . jetty . server . handler . scoped handler . handle(scoped handler . Java:135)在org . eclipse . jetty . server . handler . context handler collection . handle(handle
有没有人可以帮助我解决这个问题,这是我的源代码
蓝图
<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>
订阅服务
public interface WbSubscriptionService {
public List<WB_subscriptions> getSubscriptions();
}
变压器
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;
}
提前感谢:D
好吧,错误消息只是说返回类型必须是WB_subscriptions的集合,
而不是单个WB_subscriptions
。
您可以阅读错误消息的第一部分,如下所示:
[
=但是,从Web服务返回Java集合时存在一些问题(例如这个)。
因此,请尝试返回一个< code>WB_subscriptions数组,或者将< code>List包装在一个Bean中,然后返回包含该列表的单个Bean。