Java SOAP Message getSoapMessageString(SOAPMessage message)

Here you can find the source of getSoapMessageString(SOAPMessage message)

Description

get Soap Message String

License

Open Source License

Declaration

public static String getSoapMessageString(SOAPMessage message) 

Method Source Code


//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
    }
}

Related

  1. getSOAPMessage(InputStream in)
  2. getSOAPMessage(InputStream is)
  3. getSOAPMessage(Map headerMap, InputStream is)
  4. getSOAPMessage(Source msg)
  5. getSOAPMessageAsString(SOAPMessage soapMessage)
  6. getSOAPMsgFactory()
  7. getString(SOAPMessage msg)
  8. hasAttachments(SOAPMessage message)
  9. invokeOneWay(Dispatch dispatch, String request, String... args)