java - Cleaning up a soap request using SOAPConnectionFactory -
i'm new soap , found example of how request here: working soap client example
using chrome plugin i've managed find soap query string works is:
<envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <body> <getmyprojectcharges xmlns="http://company.iwweb.data.service.projectcharges"> <employee>26270</employee> <fiscalyear>2015</fiscalyear> <apikey>apikey</apikey> <appname>appname</appname> </getmyprojectcharges> </body> </envelope>
so trying code posted stack post wrote:
private static soapmessage createsoaprequest() throws exception { messagefactory messagefactory = messagefactory.newinstance(); soapmessage soapmessage = messagefactory.createmessage(); soappart soappart = soapmessage.getsoappart(); string serveruri = "http://schemas.xmlsoap.org/soap/envelope/"; // soap envelope soapenvelope envelope = soappart.getenvelope(); /* constructed soap request message: <soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:example="http://ws.cdyne.com/"> <soap-env:header/> <soap-env:body> <example:verifyemail> <example:email>mutantninja@gmail.com</example:email> <example:licensekey>123</example:licensekey> </example:verifyemail> </soap-env:body> </soap-env:envelope> */ // soap body soapbody soapbody = envelope.getbody(); soapelement soapbodyelem = //soapbody.addchildelement("getmyprojectcharges"); soapbody.addchildelement("getmyprojectcharges", "", "http://company.iwweb.data.service.projectcharges"); soapelement soapbodyemployee = soapbodyelem.addchildelement("employee").addtextnode("26270"); soapelement soapbodyfiscalyear = soapbodyelem.addchildelement("fiscalyear").addtextnode("2015"); soapelement soapbodyapikey = soapbodyelem.addchildelement("apikey").addtextnode("apikey"); soapelement soapbodyappname = soapbodyelem.addchildelement("appname").addtextnode("appname"); mimeheaders headers = soapmessage.getmimeheaders(); headers.addheader("soapaction", serveruri + "getmyprojectcharges"); soapmessage.savechanges(); /* print request message */ system.out.print("request soap message:"); soapmessage.writeto(system.out); system.out.println(); return soapmessage; }
however i'm ending following soap request code:
<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> <soap-env:header/> <soap-env:body> <getmyprojectcharges xmlns="http://company.iwweb.data.service.projectcharges"> <employee>26270</employee> <fiscalyear>2015</fiscalyear> <apikey>apikey</apikey> <appname>appname</appname> </getmyprojectcharges> </soap-env:body> </soap-env:envelope>
which server doesn't seem happy about. there easy way modify i'm doing query string closer want?
Comments
Post a Comment