开发者

Custom authentication in suds library (Python)

开发者 https://www.devze.com 2023-02-19 07:06 出处:网络
I need to access a SOAP server with WSDL where the authentication is done by sending two parameters, UserId and AccessToken. I tried this way:

I need to access a SOAP server with WSDL where the authentication is done by sending two parameters, UserId and AccessToken. I tried this way: token = UsernameToken( UserId, AccessToken ) token.setnonce() token.setcreated()

security = Security()
security.tokens.append(token)


client = 开发者_如何学运维Client(URL)
client.set_options(wsse=security)

and suds throwed this error

URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>

How do I add this parameters to my request? Or am I doing something else wrong?


If the parameters are supposed to part of a header, you can do it that way:

header = client.factory.create('HeaderNameInWSDL')
header.UserId = 'foo'
header.AccessToken = 'bar%n3'
client.set_options(soapheaders=header)

Then do you stuff.

0

精彩评论

暂无评论...
验证码 换一张
取 消