Java SOAP Message getSOAPMessage(Map headerMap, InputStream is)

Here you can find the source of getSOAPMessage(Map headerMap, InputStream is)

Description

Parses SOAP message from InputStream with headers.

License

Open Source License

Parameter

Parameter Description
headerMap headers
is InputStream (for client)

Declaration

public static SOAPMessage getSOAPMessage(Map<String, String> headerMap, InputStream is)
        throws SOAPException, IOException 

Method Source Code

//package com.java2s;

import java.io.IOException;
import java.io.InputStream;

import java.util.Map;
import java.util.Map.Entry;

import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPException;

import javax.xml.soap.SOAPMessage;

public class Main {
    /** SOAP */// w  w w. java 2 s . c o  m
    private static MessageFactory mf;

    /**
     * Parses SOAP message from InputStream with headers.
     * @param headerMap headers
     * @param is InputStream
     * (for client) 
     */
    public static SOAPMessage getSOAPMessage(Map<String, String> headerMap, InputStream is)
            throws SOAPException, IOException {
        MimeHeaders mimeHeaders = new MimeHeaders();
        for (Entry<String, String> entry : headerMap.entrySet()) {
            mimeHeaders.addHeader(entry.getKey(), entry.getValue());
        }

        SOAPMessage soapMessage = mf.createMessage(mimeHeaders, is);
        soapMessage.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
        //soapMessage.writeTo(System.out);

        return soapMessage;
    }
}

Related

  1. getSoapFaultExceptionMessage(SOAPFaultException sfe)
  2. getSOAPHeader(SOAPMessageContext smc)
  3. getSOAPHeaderElement(SOAPMessage message, String headerName, String nameSpace)
  4. getSOAPMessage(InputStream in)
  5. getSOAPMessage(InputStream is)
  6. getSOAPMessage(Source msg)
  7. getSOAPMessageAsString(SOAPMessage soapMessage)
  8. getSoapMessageString(SOAPMessage message)
  9. getSOAPMsgFactory()