我想使用 apache camel 路由发出 SOAP 请求。我尝试过cxf,http4,netty4-http。没有任何效果。我想要类似的东西
from("direct:start")
.to(myEndpoint)//should make soap call
.process(new Processor(){
public void process(Exchange e){
Log.debug(exchange.getIn().getBody().toString());//Should print returned value
}
})
我尝试过的包括
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="wsClient">
<from uri="direct:start" />
<to
uri="cxf:bean:productServiceEndpoint" />
</route>
</camelContext>
<cxf:cxfEndpoint id="productServiceEndpoint"
address="http://www.webservicex.com/country.asmx" wsdlURL="http://www.webservicex.com/country.asmx?wsdl" />
这表示需要服务类。我不明白。我正在消费它。为什么我需要服务类?
下一个:
from("direct:start")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
// TODO Auto-generated method stub
exchange.getOut().setBody(
"<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://www.webserviceX.NET"> <soap:Header/> <soap:Body> <web:GetCountries/> </soap:Body></soap:Envelope>");
}
})
.to("http4://www.webservicex.com/country.asmx")
.process(new Processor(){
@Override
public void process(Exchange exchange) throws Exception {
// TODO Auto-generated method stub
System.out.println(""+exchange.getExchangeId());
System.out.println(""+exchange.getIn().getBody());
System.out.println(""+exchange.getIn().getBody());
}
})
这和netty4-http不会产生任何东西。
检查你的代码,以便写入 IN 交换而不是 OUT 交换。from("直接:开始"(.process(new Processor(( {
@Override
public void process(Exchange exchange) throws Exception {
// TODO Auto-generated method stub
**exchange.getIn()**.setBody(
"<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://www.webserviceX.NET"> <soap:Header/> <soap:Body> <web:GetCountries/> </soap:Body></soap:Envelope>");