Here you can find the source of createSOAPRequestForPartnerCategories( String userId)
private static SOAPMessage createSOAPRequestForPartnerCategories( String userId) throws Exception
//package com.java2s; //License from project: LGPL import java.io.ByteArrayOutputStream; import javax.xml.soap.MessageFactory; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPMessage; import javax.xml.soap.SOAPPart; public class Main { private static SOAPMessage createSOAPRequestForPartnerCategories( String userId) throws Exception { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); String serverURI = "http://service.entitlement.siemens.com"; // SOAP Envelope SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration("ser", serverURI); envelope.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance"); // SOAP Body //<ser:getCompanyByUserId soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> //<request xsi:type="urn:CompanyByUserIdRequest" xmlns:urn="urn:model.service.entitlement.siemens.com"> SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyElem = soapBody.addChildElement( "getCompanyByUserId", "ser"); soapBodyElem/* w w w.j av a2 s . c o m*/ .setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding"); SOAPElement soapBodyElem0 = soapBodyElem.addChildElement("request"); soapBodyElem0 .setAttribute("xsi:type", "urn:CompanyByUserIdRequest"); soapBodyElem0.setAttribute("xmlns:urn", "urn:model.service.entitlement.siemens.com"); SOAPElement soapBodyElem1 = soapBodyElem0 .addChildElement("applicationId"); soapBodyElem1.addTextNode("bolayer"); soapBodyElem1 .setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding"); SOAPElement soapBodyElem2 = soapBodyElem0.addChildElement("userId"); soapBodyElem2.addTextNode(userId); soapBodyElem2 .setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding"); MimeHeaders headers = soapMessage.getMimeHeaders(); headers.addHeader("SOAPAction", serverURI + "CompanyByUserIdRequest"); ByteArrayOutputStream os = new ByteArrayOutputStream(); //soapMessage.writeTo(os); soapMessage.saveChanges(); return soapMessage; } }