rap*_*ael 6 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)
Run Code Online (Sandbox Code Playgroud)
密码:
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)
Run Code Online (Sandbox Code Playgroud)
然后我明白了zeep.exceptions.ValidationError: Missing element param_i_didnt_set.看config.__values__演出
OrderedDict([('param1', 'something'),
('param_i_didnt_set', None), ...])
Run Code Online (Sandbox Code Playgroud)
该suds config对象的类似之处在于它包含许多带有空变量的键,但suds不会抛出ValidationErrors.
从这个 Github 问题中,我看到了zeep.xsd.SkipValue. 所以我用 None 替换了任何参数config:
for key in config:
if config[key] is None:
config[key] = zeep.xsd.SkipValue
Run Code Online (Sandbox Code Playgroud)
然后client.service.exportPerUserData(username,password,config)工作...