【发布时间】:2015-05-12 11:51:17
【问题描述】:
我有以下 python 代码:
import suds
import os
import suds_passworddigest
SERVER_URL = 'http://<address>/onvif/device_service'
WSDL_URL='file:' + os.getcwd() + '/wsdl/devicemgmt.wsdl'
cli=suds.client.Client(WSDL_URL)
cli.set_options(location=SERVER_URL)
security = suds.wsse.Security()
token = suds_passworddigest.UsernameDigestToken('usr', 'password')
#token.setnonce(token.setonce()) # token.setonce() didn't work for me
security.tokens.append(token)
cli.set_options(wsse=security)
list_of_methods = [method for method in cli.wsdl.services[0].ports[0].methods]
print list_of_methods
res=cli.service.GetDNS()
print res
它给出了
AttributeError: 'module' 对象没有属性 'UsernameDigestToken'
我检查了我的导入并查看了 suds-passworddigest 的源代码,它具有 UsernameDigestToken 属性,所以为什么我会收到此错误。
【问题讨论】: