Wrap and unwrap XML with SOAP envelope in Java 1.5

pypeWalse

New Member
I have an XML document as a string which is a SOAP request without the SOAP envelope. I now need to do the following:
  • Post the request to a web service wrapped in a SOAP envelope
  • Return the response with its SOAP envelope unwrapped
The actual HTTP connection stuff is fine, but I'm really struggling with the wrapping and unwrapping. I've tried to figure out how to do this XML manipulation in Java, but can't really figure it out. Looked at the \[code\]javax.xml\[/code\] pacakge for example, but find most it to just be an enormous mess. I'm unfortunately limited to Java 1.5 and no external libraries, otherwise I'd probably used some apache commons stuff or something.Basically what I'm looking for is a pair of methods like this:\[code\]/* Wraps the xml in a standard soap envelope */String wrap(String xml)/* Removes soap envelope from the xml */String unwrap(String xml)\[/code\]The \[code\]wrap\[/code\] method I suppose could be as simple as \[code\]soapStart + xml + soapEnd\[/code\], although the xml header could mess things up if not careful. But the unwrapping gets too tricky for me as you need to actually extract what's in the \[code\]<soapenv:Body>\[/code\] and make sure you get needed namespace declarations and such with you.I've been sitting here for hours and I still have no idea... hopefully some of you guys do :)
 
Back
Top