Here you can find the source of getSOAPMessage(Map
Parameter | Description |
---|---|
headerMap | headers |
is | InputStream (for client) |
public static SOAPMessage getSOAPMessage(Map<String, String> headerMap, InputStream is) throws SOAPException, IOException
//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; } }