Link to home
Start Free TrialLog in
Avatar of Israr Ahmad
Israr Ahmad

asked on

Soap Message from XML file using private key (SSL)

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
Avatar of mccarl
mccarl
Flag of Australia image

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

Avatar of Israr Ahmad
Israr Ahmad

ASKER

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.
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.
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.
I have resolved it.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.