【发布时间】:2018-08-19 10:08:06
【问题描述】:
我想使用 apache 骆驼路由发出 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" />
这表示需要 serviceClass。我不明白。我正在消费它。为什么需要服务类?
下一步:
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 不会生成任何东西。
【问题讨论】:
-
查看现有的 Web 服务示例以获得灵感并阅读/学习更多内容:github.com/apache/camel/tree/master/examples#examples
-
谢谢。我通过了他们。我无法理解他们。我正在寻找 from("direct:start") .to(myEndpoint)//should make soap call .process(new Processor(){ public void process(Exchange e){ Log.debug(exchange.getIn().getBody ().toString());//应该打印返回值 } }) .所以如果有人以前做过,他们可以分享他们的方法,我可以继续前进。
标签: java maven apache-camel camel-cxf