获取zeep.exceptions.ValidationError:缺少使用suds

时间:2017-09-05 20:11:18

标签: python soap-client suds zeep

我正在将使用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

1 个答案:

答案 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)工作......