2017-09-05 109 views
0

我正在將使用suds 0.6開發的代碼移植到zeep 2.4.0Getting zeep.exceptions.ValidationError:缺少使用泡泡的方法的元素

上肥皂水代碼:

client = Client(WSDLfile, proxy=proxy, faults=True) 
config = client.factory.create('perUserDataExportConfiguration') 
config.param1 = 'something' 
... 
data = client.service.exportPerUserData(username,password,config) 

ZEEP代碼:

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), ...]) 

sudsconfig對象,因爲它包含了一些空變量鍵類似,但suds不會拋出ValidationErrors

回答

0

this Github issue我看到了使用zeep.xsd.SkipValue。所以我做了在config與更換無任何參數:

for key in config: 
    if config[key] is None: 
     config[key] = zeep.xsd.SkipValue 

然後client.service.exportPerUserData(username,password,config)工作...