java - How to add raw XML text to SOAPBody element -


i have xml text generated application, , need wrap soap envelope around , later make web service call.

the following code builds envelope, don't know how add existing xml data soapbody element.

    string rawxml = "<some-data><some-data-item>1</some-data-item></some-data>";      // start api     messagefactory mf = messagefactory.newinstance();     soapmessage request = mf.createmessage();     soappart part = request.getsoappart();     soapenvelope env = part.getenvelope();      // body. how add raw xml directly body?     soapbody body = env.getbody(); 

i have tried body.addtextnode() adds content < , others escaped.

the following adds xml document:

document document = convertstringtodocument(rawxml); body.adddocument(document); 

document creation:

private static document convertstringtodocument(string xmlstr) {     documentbuilderfactory factory = documentbuilderfactory.newinstance();     documentbuilder builder;     try {         builder = factory.newdocumentbuilder();         document doc = builder.parse(new inputsource(new stringreader(xmlstr)));         return doc;     } catch (exception e) {         e.printstacktrace();     }     return null; } 

i took convertstringtodocument() logic this post.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -