加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 使用Web服务导致“无法处理没有有效操作参数的请求”

发布时间:2020-12-16 07:24:45 所属栏目:asp.Net 来源:网络整理
导读:我需要在此.NET站点上使用Web服务: https://www.iyardiasp.com/8223third_17/webservices/ItfResidentData.asmx 对于初步消费,我使用Fiddler或curl.两者都给出了同样的错误: faultstringUnable to handle request without a valid action parameter. Pleas
我需要在此.NET站点上使用Web服务:

https://www.iyardiasp.com/8223third_17/webservices/ItfResidentData.asmx

对于初步消费,我使用Fiddler或curl.两者都给出了同样的错误:

<faultstring>Unable to handle request without a valid action parameter. Please supply a valid soap action.</faultstring>

我的卷曲命令:

curl -d @ GetVersionNumber.xml https://www.iyardiasp.com/8223third_17/webservices/ItfResidentData.asmx

请参阅下面的文件GetVersionNumber.xml:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
    <GetVersionNumber xmlns="http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData" />
</soap:Body>
</soap:Envelope>

添加SOAP-ENV:Header作为soap中的元素:Envelope没有帮助

<SOAP-ENV:Header Content-Type="text/xml" Host="www.iyardiasp.com" SOAPAction="http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData/GetVersionNumber"/>

将Soap Action添加为标头无济于事.

在这种情况下,curl命令是:

curl -H“SOAPAction:http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData/GetVersionNumber”-d @ GetVersionNumber.xml“https://www.iyardiasp.com/8223third_17/webservices/itfapplicantscreening.asmx”

响应是:

<faultstring>Server did not recognize the value of HTTP Header SOAPAction: http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData/GetVersionNumber.</faultstring>

解决方法

您需要提供 SOAPAction as a HTTP header,而不是SOAP标头.以下是使用SoapUI执行完整请求时的样子(请注意第四行):

POST /8223third_17/webservices/ItfResidentData.asmx HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData/GetVersionNumber"
User-Agent: Jakarta Commons-HttpClient/3.1
Host: www.iyardiasp.com
Content-Length: 260

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:itf="http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData">
   <soapenv:Body>
      <itf:GetVersionNumber/>
   </soapenv:Body>
</soapenv:Envelope>

对于curl,您可以使用-H参数发送SOAPAction标头,但我建议您使用use SoapUI进行初步使用(默认情况下它包含SOAPAction标头,并且可以在任何时候击败控制台).

如果你确实需要使用curl,请尝试这样的事情(所有必须在一行;为了便于阅读,将其分开):

curl -H "Content-Type: text/xml;charset=UTF-8" 
     -H "SOAPAction: "http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData/GetVersionNumber"" 
     -d @GetVersionNumber.xml 
     https://www.iyardiasp.com/8223third_17/webservices/ItfResidentData.asmx

在GetVersionNumber.xml文件中使用它:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:itf="http://tempuri.org/YSI.Interfaces.WebServices/ItfResidentData">
   <soapenv:Body>
      <itf:GetVersionNumber/>
   </soapenv:Body>
</soapenv:Envelope>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读