public static String messageToString ( SOAPMessage soapMessage ) { String strTextMessage = null ; if ( soapMessage != null ) { try { ByteArrayOutputStream ba = new ByteArrayOutputStream ( ) ; PrintStream os = new PrintStream ( ba ) ; soapMessage . writeTo ( os ) ; os . flush ( ) ; ByteArrayInputStream is = new ByteArrayInputStream ( ba . toByteArray ( ) ) ; Reader reader = new InputStreamReader ( is ) ; BufferedReader br = new BufferedReader ( reader ) ; StringBuffer sb = new StringBuffer ( ) ; String string = null ; while ( ( string = br . readLine ( ) ) != null ) { sb . append ( string ) ; sb . append ( ' ' ) ; } strTextMessage = sb . toString ( ) ; } catch ( SOAPException ex ) { ex . printStackTrace ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } } return strTextMessage ; }
Convert this SOAP message to a text string .