OK I have java code which creates the following XML SOAP message:
I need the message to have a header before the xml code so it would look like:
The java code I have used to create this message is as follows:
Could someone please help me out!
Code:
<?xml version="1.0" encoding="UTF-8"?> <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> <soap-env:Header/> <soap-env:Body> <GetAppList xmlns="https://***.***.***.***/***/***.asmx"> <requestId>1</requestId> <laNumber>5</laNumber> <hashCode>123456</hashCode> </GetAppList> </soap-env:Body></soap-env:Envelope>
Code:
Host: ***.***.***.*** Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://***.***.***.***/***/***" <?xml version="1.0" encoding="UTF-8"?> <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Header/><soap-env:Body><GetAppList xmlns="https://***.***.***.***/***/***.asmx"> <requestId>1</requestId> <laNumber>5</laNumber> <hashCode>123456</hashCode> </GetAppList> </soap-env:Body></soap-env:Envelope>
Code:
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();
SOAPFactory soapFactory = SOAPFactory.newInstance();
Name bodyName = soapFactory.createName("GetAppList","","https://***.***.***.***/***/***.asmx");
SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
//Create nodes for sending requestId, laNumber and hashCode
Name nameRequestId = soapFactory.createName("requestId");
SOAPElement requestId = bodyElement.addChildElement(nameRequestId);
requestId.addTextNode("1");
Name nameLaNumber = soapFactory.createName("laNumber");
SOAPElement laNumber = bodyElement.addChildElement(nameLaNumber);
laNumber.addTextNode(lpaCode);
Name nameHashCode = soapFactory.createName("hashCode");
SOAPElement hashCode = bodyElement.addChildElement(nameHashCode);
hashCode.addTextNode(encryptedHashCode);
Comment