我正在将使用suds 0.6
开发的代码移植到zeep 2.4.0
。
以前的泡沫代码:
client = Client(WSDLfile, proxy=proxy, faults=True)
config = client.factory.create('perUserDataExportConfiguration')
config.param1 = 'something'
...
data = client.service.exportPerUserData(username,password,config)
密码:
session = requests.Session()
session.verify = False
transport = Transport(session=session)
client = Client(WSDLfile, strict=False, transport=transport)
config = client.type_factory('ns0').perUserDataExportConfiguration()
config.param1 = 'something'
...
data = client.service.exportPerUserData(username,password,config)
然后我得到zeep.exceptions.ValidationError: Missing element param_i_didnt_set
。展望config.__values__
节目
OrderedDict([('param1', 'something'),
('param_i_didnt_set', None), ...])
suds
config
对象类似,因为它包含许多带有空变量的键,但suds
不会抛出ValidationErrors
。
答案 0 :(得分:2)
从this Github issue我看到zeep.xsd.SkipValue
的使用。所以我用config
替换了任何带有None的参数:
for key in config:
if config[key] is None:
config[key] = zeep.xsd.SkipValue
然后client.service.exportPerUserData(username,password,config)
工作......