Hi,
I have a requirement "While routing in camel, i have to call a web
service". But i am struck with setting SOAP xml to the exchange. Can some
one help me with this. Please have a look at my code
public static void main(String[] args) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("file:input?noop=true")
.process(new Processor() {
@Override
public void process(Exchange exchange)
throws Exception {
//Setting a String to the exchange body
exchange.getIn().setBody("Just a String");
//Now i want to set a SOAP xml to the
exchange body
//exchange.getIn().setBody();
System.out.println("Ravi "+
exchange.getIn().getBody(String.class));
}
})
.to("cxf://http://www.webservicex.net/stockquote.asmx?wsdlURL=src/main/resources/META-INF/stockquote.wsdl&serviceName={http://www.webserviceX.NET/}StockQuote&portName={http://www.webserviceX.NET/}StockQuoteSoap&dataFormat=MESSAGE")
.process(new Processor() {
@Override
public void process(Exchange exchange)
throws Exception {
System.out.println("Raju" + exchange);
}
}).to("file:data/destination?fileName=test2.xml");
}
});
context.start();
Thread.sleep(20000);
context.stop();
}
~Raju