http调用webservice接口返回错误:no SOAPAction header解决方法

本文详细解析了在调用WebService接口时遇到的'NoSOAPAction'错误,提供了具体的解决方法,包括如何正确设置SOAPAction头,以及查找正确的SOAPAction值的方法。同时,文章附带了相关参考资料,帮助读者深入理解SOAP和WSDL在WebService中的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误消息:
<?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/">host1</ns2:hostname>
   </detail>
  </soapenv:Fault>
 </soapenv:Body>

 

解决方法,
    //HttpURLConnection连接,需设置 SOAPAction Header :
    connect.setRequestProperty("SOAPAction","");//参数2可以是任意字符串,我写的url
    
        //SOAPAction正确值,应该查看:url.wsdl 的:<soap:operation soapAction="..." />

参考:

https://blog.youkuaiyun.com/wxyong3/article/details/38727503

https://blog.youkuaiyun.com/etttttss/article/details/21624313

推荐:根据结果搜索,健全的http调用webservice接口方法,写的比较清晰

https://www.cnblogs.com/eleven258/p/7157419.html?utm_source=itdadao&utm_medium=referral

SOAP和WSDL对Web Service、WCF进行深入了解的基础

https://www.cnblogs.com/JeffreySun/archive/2009/12/14/1623766.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值