private InputStream getSOAPBodyStream(Document doc) throws Exception {
System.setProperty(DOMImplementationRegistry.PROPERTY,
"com.sun.org.apache.xerces.internal.dom.DOMImplementationSourceImpl");
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS");
LSOutput output = impl.createLSOutput();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
output.setByteStream(byteArrayOutputStream);
LSSerializer writer = impl.createLSSerializer();
writer.write(doc, output);
byte[] buf = byteArrayOutputStream.toByteArray();