Apache camel 使用CXF从驼峰路由调用无参数webservice操作

Apache camel 使用CXF从驼峰路由调用无参数webservice操作,apache-camel,cxf,Apache Camel,Cxf,ThingsService是一个由jax ws生成的Web服务接口(为了简洁起见去掉了注释)。有一种无参数方法: public interface ThingsService { AvailableThingsResponse getAvailableThings(); } 尝试使用CXF从驼峰路由调用无参数操作,如下所示: from("timer:start?fixedRate=true") .setHeader(CxfConstants.OPERATION_NAME

ThingsService
是一个由jax ws生成的Web服务接口(为了简洁起见去掉了注释)。有一种无参数方法:

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());
调用终结点时导致驼峰呕吐:

java.lang.IllegalArgumentException:获取错误的 调用out服务的参数大小,大小应为0,参数 1号。请检查消息正文是否与CXFENDPOJO点匹配 数据格式请求。 位于org.apache.camel.component.cxf.CxfProducer.checkParameterSize(CxfProducer.java:283) 位于org.apache.camel.component.cxf.CxfProducer.getParams(CxfProducer.java:321) 位于org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:131) 位于org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145) 位于org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77) 位于org.apache.camel.processor.RedeliveryRorHandler.process(RedeliveryRorHandler.java:542) 位于org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197) 位于org.apache.camel.processor.Pipeline.process(Pipeline.java:120) 位于org.apache.camel.processor.Pipeline.process(Pipeline.java:83) 位于org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197) 位于org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:192) 位于org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:76) 位于java.util.TimerThread.mainLoop(Timer.java:555) 运行(Timer.java:505)

CXF终结点处于POJO模式,发送到终结点的exchange正文为null


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

结果表明,没有参数是使用空数组表示的:

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());

我记录了一张罚单以简化操作:。您使用的是什么版本的Apache Camel?@ClausIbsen最新版本,2.18.1。