2016-12-15 126 views
0

ThingsService是由jax-ws生成的web服务接口(为了简洁起见,除去了注释)。有一个无参数的方法,包括:使用CXF从骆驼路由调用无参数web服务操作使用CXF

public interface ThingsService { 
    AvailableThingsResponse getAvailableThings(); 
} 

试图从使用CXF这样的骆驼路由调用无参数操作:

from("timer:start?fixedRate=true") 
     .setHeader(CxfConstants.OPERATION_NAME, constant("getAvailableThings") 
     .to("cxf:http://localhost:8080/services/things" 
      + "?serviceClass=" + ThingsService.class.getName()); 

导致骆驼主叫端点时BARF:

java.lang.IllegalArgumentException:获取错误的 参数大小来调用out服务,期望大小0,参数 大小1.请检查消息b ody匹配CXFEndpoint POJO Dataformat请求。 at org.apache.camel.component.cxf.CxfProducer.checkParameterSize(CxfProducer.java:283) at org.apache.camel.component.cxf.CxfProducer.getParams(CxfProducer.java:321) at org.apache。 camel.component.cxf.CxfProducer.process(CxfProducer.java:131) at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145) at org.apache.camel.management.InstrumentationProcessor.process( InstrumentationProcessor.java:77) 在org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542) 在org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197) 的组织。 apache.camel.processor.Pipeline.process(Pipeline.java:120) at org.apache.camel.processor.Pipeline.proc (org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197) at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:192) at org.apache.camel.component.timer.TimerConsumer $ 1.run(TimerConsumer.java:76) at java.util.TimerThread.mainLoop(Timer.java:555) at util.TimerThread.run(Timer.java :505)

CXF端点处于POJO模式,正在发送到端点的交换主体为空。

什么是使用CXF组件从骆驼路由调用无参数WS操作的正确方法?

回答

0

原来,没有params为使用空数组表示:

from("timer:start?fixedRate=true") 
     .setHeader(CxfConstants.OPERATION_NAME, constant("getAvailableThings") 
     .transform().body(o -> new Object[0]) 
     .to("cxf:http://localhost:8080/services/things" 
      + "?serviceClass=" + ThingsService.class.getName()); 
+1

我登录票使它更容易些:https://issues.apache.org/jira/browse/CAMEL-10607 。 –

+0

你使用的是什么版本的Apache Camel? –

+0

@ClausIbsen最近的,2.18.1。 – prook