Hello!
我正在尝试使用 Java DSL 和 RouteBuilder 实现 Camel 路线。我想从计时器端点发送到 cxf 端点。
Code:
public class MyRoute extends RouteBuilder {
@Override
public void configure() {
CamelContext camelContext = getContext();
CxfEndpoint cxfEndpoint = new CxfEndpoint();
cxfEndpoint.setAddress("http://localhost:8088/interface");
cxfEndpoint.setWsdlURL("wsdl/contract.wsdl");
cxfEndpoint.setCamelContext(camelContext);
cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);
try {
camelContext.addEndpoint("myEndpoint", cxfEndpoint);
} catch (Exception e) {
e.printStackTrace();
}
from("timer://my-timer?fixedRate=true&period=500")
.transform(constant("DummyBody"))
.to("cxf://myEndpoint");
}
}
该路由被插入到使用 Spring XML 定义的骆驼上下文中(其中我还有一些其他路由)。
Problem:
我收到以下错误:
karaf@root> Exception in thread "SpringOsgiExtenderThread-78" org.apache.camel.FailedToCreateProducerException: Failed to create Producer fo
r endpoint: Endpoint[cxf://myEndpoint]. Reason: java.lang.IllegalArgumentException: serviceClass must be specified
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:395)
at org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:114)
at org.apache.camel.impl.ProducerCache.startProducer(ProducerCache.java:145)
at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:175)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
....
现在错误非常简单,但是here http://camel.apache.org/cxf.html says:
仅 POJO 模式需要此选项。如果 wsdlURL 选项是
前提是,PAYLOAD 和 MESSAGE 模式不需要 serviceClass。
问题:
如果我使用 PAYLOAD 模式,为什么我仍然需要服务类?创建 cxf 端点时我是否遗漏了某些内容?
Thanks!
您已经设置了要使用的 CxfEndpoint,因此您的路线应该像这样
from("timer://my-timer?fixedRate=true&period=500")
.transform(constant("DummyBody"))
.to(myEndpoint);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)