7

我正在移植使用suds 0.6over to开发的代码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)

zeep代码:

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

4

1 回答 1

6

这个 Github issue我看到了zeep.xsd.SkipValue. 所以我用 None 替换了任何参数config

for key in config:
    if config[key] is None:
        config[key] = zeep.xsd.SkipValue

然后client.service.exportPerUserData(username,password,config)工作...

于 2017-09-05T20:21:44.323 回答