I have Structure given below
< soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:SRM_RequestInterface_WS">
< soapenv:Header>
<urn:AuthenticationInfo>
<urn:userName>admin</urn:userName>
<urn:password>Password</urn:password>
</urn:AuthenticationInfo>
< / soapenv: Header>
< soapenv:Body>
<urn:Request_Query_Service>
<urn:Request_Number>REQ00000041</urn:Request_Number>
</urn:Request_Query_Service>
< /soapenv:Body>
< /soapenv:Envelope>
I have written code for the above request in Java
private static SOAPMessage createSOAPRequest(Map params) throws Exception
{
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
String serverURI = "urn:SRM_RequestInterface_WS";
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("urn", serverURI);
SOAPHeader header=envelope.getHeader();
SOAPElement soapBodyElem = header.addChildElement("AuthenticationInfo", "urn");
SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("userName");
soapBodyElem1.addTextNode("admin");
SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("password");
soapBodyElem2.addTextNode("Password1!");
SOAPBody soapBody = envelope.getBody();
SOAPElement soapBodyElem3 = soapBody.addChildElement("Request_Query_Service", "urn");
SOAPElement soapBodyElem4 = soapBodyElem3.addChildElement("Request_Number");
soapBodyElem4.addTextNode("REQ00000041");
soapMessage.saveChanges();
ByteArrayOutputStream out = new ByteArrayOutputStream();
if(Validator.isNotNull(out)){
soapMessage.writeTo(out);
}
return soapMessage;
}
Error occurred while sending SOAP Request to Server com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: java.security.PrivilegedActionException: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Message send failed"
Can Someone TELL Above java program to get correct structure for given SOAP request is correctly written or not ??