Python + SOAP : The message with Action \'\' cannot be processed at the receiver, 由于 EndpointDispatcher 的 ContractFilter 不匹配

标签 python soap wsdl python-requests

尝试使用 python 请求访问此 soap 网络服务:http://bsestarmfdemo.bseindia.com/MFUploadService/MFUploadService.svc?WSDL

这是我的要求:

import requests
url="http://bsestarmfdemo.bseindia.com/MFUploadService/MFUploadService.svc?WSDL"
#headers = {'content-type': 'application/soap+xml'}
headers = {'content-type': 'application/soap+xml'}
body = """<?xml version="1.0" encoding="UTF-8"?>
         <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
   <soap:Header/>
   <soap:Body>
      <tem:getPassword>
         <!--Optional:-->
         <tem:UserId>1003201</tem:UserId>
         <!--Optional:-->
         <tem:MemberId>10032</tem:MemberId>
         <!--Optional:-->
         <tem:Password>xxxxxxxx</tem:Password>
         <!--Optional:-->
         <tem:PassKey>xxxxxx123</tem:PassKey>
      </tem:getPassword>
   </soap:Body>
</soap:Envelope>"""

response = requests.post(url,data=body,headers=headers)
print (response.content)

这是响应:

b'Sendera:ActionNotSupportedThe message with Action \'\' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).'

如果我没理解错的话,我可能需要在请求中设置操作,但不知道该怎么做。我对 python 中的 SOAP 完全陌生,请建议如何解决这个问题。 谢谢!

最佳答案

只需将 SOAPAction 添加到标题中,例如:

headers = {'Content-type': 'text/xml;charset=UTF-8',
       'SOAPAction': 'http://google.com/ISearchService/Find'
       }

关于Python + SOAP : The message with Action \'\' cannot be processed at the receiver, 由于 EndpointDispatcher 的 ContractFilter 不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37833718/

相关文章:

java - CXF 未将父类(super class)添加到生成的类中

web-services - 不使用 @XMLRootElement 注释解码 REST 响应

python - 简单建表sql适用于mysql和postgre,但在oracle中报错

java - Wildfly:Web 服务已部署但不可用

c# - Servicestack SOAP - 无效凭据返回 html 作为响应

java - 如何使用java使用webservice上传多个文件?

python - "python"仅以管理员身份从命令提示符运行

python - 如何在python中使用多线程同时下载多个文件

Python 子进程 : read returncode is sometimes different from returned code

javascript - 如何在 C# Envelope->Error 中反序列化 XML