2016-12-15 130 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