Python Forum
Zeep - BasicHTTPBinding secured Endpoint throws 500-invalid security error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Zeep - BasicHTTPBinding secured Endpoint throws 500-invalid security error (/thread-34288.html)



Zeep - BasicHTTPBinding secured Endpoint throws 500-invalid security error - vinoth - Jul-15-2021

Hi,

Greetings!!

I'm working on Python Soap client library - Zeep and struck with below issue. It would be very helpful if you can help to solve it.

SoapXML endpoint is secured with "BasicHTTPBinding WSS Type - PasswordText" authentication. I can successfully send the request manually using SoapUi tool, but in Zeep below code throws 500 internal server error.

headers = {'content-type': 'text/xml'}
url = r'https://xxxxxxxxxxxxxxxx/Services/LoansIntegrationService.svc?singleWsdl'
client = Client(url ,wsse=UsernameToken('vvasu', 'demo'))
body = client.transport.load('.\wsdl\LoanRequest.wsdl') #fetch the updated wsdl file and pass it to request
result = client.transport.post(message=body, address=url, headers=headers)
print(result.content) #An error occurred when verifying security for the message.
Response:

<s:Body>
<s:Fault>
<faultcode xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">a:InvalidSecurity</faultcode>
<faultstring xml:lang="en-US">An error occurred when verifying security for the message.</faultstring>
</s:Fault>
</s:Body>
</s:Envelope>

Kindly help!!

Thanks.