Here you can find the source of getSourceAsString(Source source)
public static String getSourceAsString(Source source) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.OutputStream; 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 getSourceAsString(Source source) throws Exception { Transformer transformer = TransformerFactory.newInstance() .newTransformer();/*ww w . ja v a 2 s . co m*/ OutputStream outputStream = new ByteArrayOutputStream(); StreamResult streamResult = new StreamResult(); streamResult.setOutputStream(outputStream); transformer.transform(source, streamResult); return streamResult.getOutputStream().toString(); } public static String getSourceAsString(SOAPMessage sm) throws Exception { ByteArrayOutputStream stream = new ByteArrayOutputStream(); sm.writeTo(stream); return stream.toString(); } }