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

最佳答案

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)起作用了...

关于python - 获取zeep.exceptions.ValidationError : Missing element for method that worked with suds,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46062682/

10-16 19:05