AttributeError: 'list' object has no attribute 'verify' when you pass in list wsse
When you pass a wsse as a list to the client, like this: client = Client(wsdl=url, transport=transport, wsse=[self.user_name_token]) or client = Client(wsdl=url, transport=transport, wsse=[self.user_name_token, self.signature])
You get an error in the process_reply, like this: response = client.service.RIDP(**input) File "/Users/cathleenturner/.local/share/virtualenvs/services-m78ruPbe/lib/python3.7/site-packages/zeep/proxy.py", line 42, in call self._op_name, args, kwargs) File "/Users/cathleenturner/.local/share/virtualenvs/services-m78ruPbe/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", line 132, in send return self.process_reply(client, operation_obj, response) File "/Users/cathleenturner/.local/share/virtualenvs/services-m78ruPbe/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", line 184, in process_reply client.wsse.verify(doc) AttributeError: 'list' object has no attribute 'verify'
The examples refer to passing in wsse as a list.
https://python-zeep.readthedocs.io/en/master/wsse.html
>>> from zeep import Client
>>> from zeep.wsse.username import UsernameToken
>>> from zeep.wsse.signature import Signature
>>> user_name_token = UsernameToken('username', 'password')
>>> signature = Signature(private_key_filename, public_key_filename,
... optional_password)
>>> client = Client(
... 'http://www.webservicex.net/ConvertSpeed.asmx?WSDL',
... wsse=[user_name_token, signature])
The workaround is to not pass it as a list, like so: client = Client(wsdl=url, transport=transport, wsse=self.user_name_token)
Would be good to get a heads up on this error in the docs before entering a rabbit hole.
We have to give both, UsernameToken and BinarySecurityToken, hence: +1
+1 Is there any workaround to give username and signature to the wsse?
+1 any progress in this issue?
+1 any progress in this issue?
For now, the workaround is to not pass it as a list. It worked for me.
@n00blet the issue is that the service I am consuming requires both token and signature verifications; so I need to pass them as a list.
+1 any progress in this issue? Or any workaround?
+1 I'm also trying to connect to a service that requires both token and signature verifications. The workaround from OP does not work in that case.
See my pull request #1077 for a fix.
While it gets fixed properly, here was my workaround:
class CustomSignature(object):
"""Sign given SOAP envelope with WSSE sig using given key and cert."""
def __init__(self, wsse_list):
self.wsse_list = wsse_list
def apply(self, envelope, headers):
for wsse in self.wsse_list:
envelope, headers = wsse.apply(envelope, headers)
return envelope, headers
def verify(self, envelope):
pass
To use it:
user_name_token = UsernameToken(user, password)
signature = Signature(private_key, signed_cert, certificate_password)
client = Client(soap_endpoint, wsse=CustomSignature([user_name_token, signature]))
Thanks @gabrielfarah you are amazing... You made my day so warn... love u...