0

Soap-request generated Java application [Failed]

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
   xmlns:dir="http://xxxxxxxxxx">
  <soapenv:Body>
    <xxxxxxxxxxx>       
  </soapenv:Body>
</soapenv:Envelope>

Soap-request generated by SoapUI [Successful]

 <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" 
   xmlns:dir="http://xxxxxxxxxx">
 <soap:Header/>
   <soap:Body>
     <dir:ping/>
   </soap:Body>
 </soap:Envelope>

How to change namespace uri "http://schemas.xmlsoap.org/soap/envelope/" to "http://www.w3.org/2003/05/soap-envelope". I haven't created any client, i have just created java class and running i'm able to send request and getting faultcode response because of the above uri links. I found it is version mismatch but i dont know how to change.

Rpa_spec
  • 21
  • 1
  • 4
  • Add your java soap client code snippet without it, its hard to answer. – Red Boy Jun 28 '18 at 07:52
  • [Link to code snippet](https://stackoverflow.com/questions/19291283/soap-request-to-webservice-with-java/19745299#19745299) I have used the same code in the answer shown in this link..... – Rpa_spec Jul 02 '18 at 04:05

2 Answers2

1

I feel that you must be using the default SOAP implementation(which is SOAP 1.2) as provided into the Statckoverflow question. Your web service may be expecting SOAP 1.1.

If you could change it SOAPMessageFactory1_1Impl implementation it should solve your problem. Your namespace will changed to xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"

Change callSoapWebService method first line to following and it should resolve the issue.

SOAPMessage soapMessage = SOAPMessageFactory1_1Impl.newInstance().createMessage();

Hope it helps.

Red Boy
  • 5,429
  • 3
  • 28
  • 41
  • Change between http://schemas.xmlsoap.org/soap/envelope/ and http://www.w3.org/2003/05/soap-envelop worked fine for me! – Windgate Feb 13 '20 at 08:33
1

MessageFactory factory = MessageFactory.newInstance(); ------ it will give 1.1 version default

change to following to get the 1.2 version of soap namespace

MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);

you can find it in SAAJ tutorials

Rpa_spec
  • 21
  • 1
  • 4