Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python + SOAP : The message with Action \'\' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher

Trying to access this soap webservice using python requests : http://bsestarmfdemo.bseindia.com/MFUploadService/MFUploadService.svc?WSDL

Here is my request :

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)

This the response :

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).'

If I understand correctly, I probably need to set the action in the request, but can't figure out how to do that. I'm entirely new to soap in python, please suggest how to fix this. Thanks!

like image 618
vivekanon Avatar asked Jun 15 '16 11:06

vivekanon


1 Answers

Just add the SOAPAction onto the header, for example:

headers = {'Content-type': 'text/xml;charset=UTF-8',
       'SOAPAction': 'http://google.com/ISearchService/Find'
       }
like image 73
Linh Hoang Avatar answered Nov 10 '22 09:11

Linh Hoang