gpt4 book ai didi

python - 获取 zeep.exceptions.ValidationError : Missing element for method that worked with suds

转载 作者:太空狗 更新时间:2023-10-30 00:09:17 25 4
gpt4 key购买 nike

我正在将使用 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 不会抛出 验证错误

最佳答案

来自 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com