Soap version mismatch in java

三世轮回 提交于 2020-01-13 07:29:07

问题


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.


回答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.




回答2:


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



来源:https://stackoverflow.com/questions/51073837/soap-version-mismatch-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!