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