【问题标题】:Python + SOAP : The message with Action \'\' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcherPython + SOAP:由于 EndpointDispatcher 的 ContractFilter 不匹配,接收方无法处理带有 Action \'\' 的消息
【发布时间】:2016-06-15 11:08:55
【问题描述】:

尝试使用 python 请求访问这个soap webservice: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:ActionNotSupported带有Action \'\'的消息无法在 接收方,由于 ContractFilter 不匹配 端点调度程序。这可能是因为合同不匹配 (发送方和接收方之间的操作不匹配)或绑定/安全性 发送者和接收者之间的不匹配。检查发件人和 接收方具有相同的合同和相同的约束力(包括 安全要求,例如消息,传输, 无)。'

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

【问题讨论】:

    标签: python soap wsdl python-requests


    【解决方案1】:

    只需将 SOAPAction 添加到头部,例如:

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

    【讨论】:

      猜你喜欢
      • 2016-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-02
      • 2011-03-28
      • 2013-09-22
      相关资源
      最近更新 更多