I want to make a SOAP request using apache camel routing. I have tried cxf, http4, netty4-http. Nothing is working. I want something like
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
}
})
What I have tried includes
<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" />
This says serviceClass required. I dont understand. I am consuming it. Why do I need service class?
Next:
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());
}
})
This and netty4-http does not generate anything.
Check your code so you write to the IN exchange and not OUT exchange. from("direct:start") .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>");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.