Here you can find the source of getSoapMessageString(SOAPMessage message)
public static String getSoapMessageString(SOAPMessage message)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import javax.xml.soap.SOAPMessage; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; public class Main { public static String getSoapMessageString(SOAPMessage message) { try (ByteArrayOutputStream outStream = new ByteArrayOutputStream()) { Source source = message.getSOAPPart().getContent(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); StreamResult streamResult = new StreamResult(outStream); transformer.transform(source, streamResult); String returnValue = outStream.toString("utf-8"); return returnValue; } catch (Exception e) { throw new IllegalStateException(e); }//w w w . ja v a 2 s . c o m } }