>>> 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.
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.
Fixes #953 - AttributeError: 'list' object has no attribute 'verify' when you pass in list wsse
#1077
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):
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]))
x509 Feat and Fix - fixes multiple wsse, add option do disable response verification, and use another cert for verify
#1429