java - Is Camel Automatically generate SOAP Message? -
is apache camel automatically generate soap message if provide required object structure?
if not why should use camel calling web service?
please provide me specific reason out calling soap web service.
my camel configuration is
camelcontext.addroutes(new routebuilder() { @override public void configure() throws exception { from("direct:start") .process(new processor() { @override public void process(exchange exchange) throws exception { system.out.println("in ........"); exchange.getin().setbody("<country>india</country>"); system.out.println("in process method"); system.out.println(exchange.getexchangeid() + " : " + exchange.getfromrouteid() + " : " + exchange.isfailed()); } }). to("cxf://http://www.webservicex.net/airport.asmx?" + "wsdlurl=http://www.webservicex.net/airport.asmx?wsdl&" + "servicename={http://www.webservicex.net}airport&" + "portname={http://www.webservicex.net}airportsoap&" + "defaultoperationname=getairportinformationbycountry&" + "dataformat=message") .to("file:/home/viral?filename=output.txt"); } });
thanks.
is apache camel automatically generate soap message if provide required object structure?
overall yes,
you don't need make soap envelop own. need write custom processor
in define soap message. plus in camelcontext
need define endpoint
, route
. handle soapfault
in case of error or can write own custom error soap responses well.
update in reply of comment :
if want make generic camel processor can add message body in xml file every time , set soapbody this
... @override public void process(exchange exchange) throws exception { system.out.println("in ........"); try { file file = new file("soapbody.xml"); // generic body in separate xml file every time documentbuilderfactory dbf = documentbuilderfactory.newinstance(); documentbuilder db = dbf.newdocumentbuilder(); document doc = db.parse(file); string body = doc.tostring(); exchange.getin().setbody(body ); } catch (exception e) { e.printstacktrace(); } system.out.println("in process method"); system.out.println(exchange.getexchangeid() + " : " + exchange.getfromrouteid() + " : " + exchange.isfailed()); } ...
Comments
Post a Comment