HttpURLConnection 请求webservice出现错误

来源:互联网 发布:php画三角形星星 编辑:程序博客网 时间:2024/05/22 14:00

出现错误:

服务器报错500

返回信息:no SOAPAction header!


<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <soapenv:Fault>
   <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode>
   <faultstring>no SOAPAction header!</faultstring>
   <detail>
    <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">test01</ns2:hostname>
   </detail>
  </soapenv:Fault>
 </soapenv:Body>
</soapenv:Envelope>


解决方案:在请求端,加上一个请求头

openConnection.setRequestProperty("SOAPAction", "\"\"");或者

openConnection.setRequestProperty("SOAPAction", "");


参考另一篇博文:http://blog.csdn.net/wxyong3/article/details/38727503

原创粉丝点击