Soap Message from XML file using private key (SSL)

Israr Ahmad
Israr Ahmad used Ask the Experts™
on
I am facing Problem when converting xml file to soap message for making a call to web service attaching my code and request  

following is the error

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:wsdl="http://xmlns.qtel.com.qa/B2B/WSDL" 
xmlns:par="http://www.tibco.com/namespaces/bc/2002/04/partyinfo.xsd">
   
   <soapenv:Header>
      <wsdl:TxInfo>
         <wsdl:Created>2018-06-10T11:07:20.953+03:00</wsdl:Created>
         <wsdl:Source>POS101</wsdl:Source>
         <wsdl:Lang>EN</wsdl:Lang>
      </wsdl:TxInfo>
      <par:PartyInfo>
         <from>
            <name>RQ</name>
         </from>
         <to>
            <name>Qtel</name>
         </to>
         <operationID>Qtel.Gateway/1.0/CheckLineStatus</operationID>
         <operationType>syncRequestResponse</operationType>
         <transactionID>RQJAV270220190000000010</transactionID>
      </par:PartyInfo>
   </soapenv:Header>


   <soapenv:Body>
      <wsdl:CheckLineStatusRequest>
         <wsdl:Request>RQ</wsdl:Request>
      </wsdl:CheckLineStatusRequest>
   </soapenv:Body>
</soapenv:Envelope>
ContentDescription >> null
Soap Header        >> [soapenv:Header: null]
Soap Part          >> com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl@37f8bb67
SOAP Body          >> [soapenv:Body: null]

Open in new window

SoapEnv.java
sample_rq.xml
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
mccarlIT Business Systems Analyst / Software Developer
Top Expert 2015

Commented:
I can't see any error in what you have posted.

BUT... I am guessing that you are worried about where it says the the Header and Body are null? If so, you don't need to be concerned. You have simply fallen into to trap of just trying to convert a DOM node to a String and print it out. This rarely (if ever) works the way you want.

You need to traverse the DOM elements that the getSOAPHeader and getSOAPBody calls return to see something more useful. Paste the following code over what you have in your sendSoapMessage method and you will see more detail and hopefully realize that it is doing what you want it to.

        try {
            NodeList nodes;
            
            System.out.println("");
            System.out.println("ContentDescription >> "+message.getContentDescription());


            System.out.println("Soap Header Contents... ");
            nodes = message.getSOAPHeader().getChildNodes();
            for (int i = 0; i < nodes.getLength(); i++) {
                Node node = nodes.item(i);
                System.out.println("\t\t" + node.getNodeName());
            }


            System.out.println("Soap Part          >> "+message.getSOAPPart());


            System.out.println("SOAP Body Contents... ");
            nodes = message.getSOAPBody().getChildNodes();
            for (int i = 0; i < nodes.getLength(); i++) {
                Node node = nodes.item(i);
                System.out.println("\t\t" + node.getNodeName());
            }
            
            
        } catch (SOAPException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

Open in new window

Author

Commented:
Hello mccarl,

Thanks, now i am able to move one step forward. My issue is i am getting error while sending a signed soap request using java class. I am getting success message when sending request using soapUI.

I am attaching four files which will help in investigation

1- Request payload from soupUI - getting success message
2- request payload from Java class - not  success
3- Error message i am getting while snding request from java class
4- Java class
5- soapUI outgoing request security configuration

I am struggling for making a successful SSL call even i am sending same Request payload of soupUI from java still getting same error.
i will be grateful for quick support.

Author

Commented:
There is a difference between both the request between Req_SoapUI.xml and signature_rq.xml. Server is expecting the request like Req_SoapUI.xml.
Any suggestion and help is appreciable.

Author

Commented:
I figure out the requirement

Sign XML request using OASIS SHA1 in Java

We need to sign a request and add that security tag to the Soap Request, we need to use OASIS standard

the requirements for the sign are

Standard  - OASIS
Keystore  - pfx
Key Identifier - X509 CERTIFICATE
Signature Algorithm - rsa-sha1
Canonicalization - exc-c14n
Digesest Algorithm - sha1
Authorisation - NTLM
Strip whitespaces - true

We Want to sign our generated request xml, the code we want will receive an string and produce a sign
Attaching the request file and signed file (Req_SoapUI.xml)format.

Author

Commented:
I have resolved it.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial