我正在尝试构建简单的Camel路由到公共Web服务,
http://wsf.cdyne.com/WeatherWS/Weather.asmx
我使用最新的Camel与Spring,CXF,SOAP和Java配置模块。
这是我的CxfEndpoint:
@Bean(name = "testCxfBean")
public CxfEndpoint createTestEndpoint() throws ClassNotFoundException {
CxfEndpoint endpoint = new CxfEndpoint();
endpoint.setAddress("http://wsf.cdyne.com/WeatherWS/Weather.asmx");
endpoint.setWsdlURL("http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL");
endpoint.setEndpointNameString("WeatherSoap");
endpoint.setServiceNameString("Weather");
return endpoint;
}

这是我的路线:
@Component
public class TestCXFRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
SoapJaxbDataFormat dataFormat = new SoapJaxbDataFormat("com.cdyne.ws.weatherws", new ServiceInterfaceStrategy(
WeatherSoap.class, true));
from("timer:testTimer?period=5000").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody(new GetWeatherInformation());
}
}).setHeader("operationName", constant("GetWeatherInformation")).marshal(dataFormat)
.to("cxf:testCxfBean?serviceClass=com.cdyne.ws.weatherws.WeatherSoap").log("level:info");
}
}

我在这里尝试做的是每5秒查询一次天气信息,使用GetWeatherInformation操作,编组相关对象,只记录结果。
但是我收到了这样的错误:
Exchange[
Id ID-darkstar-dev-39021-1423838783518-0-4
ExchangePattern InOnly
Headers {breadcrumbId=ID-darkstar-dev-39021-1423838783518-0-3, CamelRedelivered=false, CamelRedeliveryCounter=0, firedTime=Fri Feb 13 15:46:31 CET 2015, operationName=GetWeatherInformation}
BodyType byte[]
Body <?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns2:Envelope xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns3="http://ws.cdyne.com/WeatherWS/"> <ns2:Body> <ns3:GetWeatherInformation/> </ns2:Body></ns2:Envelope>
]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.IllegalArgumentException: Get the wrong parameter size to invoke the out service, Expect size 0, Parameter size 252. Please check if the message body matches the CXFEndpoint POJO Dataformat request.
&#13;
我做错了什么?