使用Python zeep无法使用多个WSDL

时间:2018-02-06 15:11:53

标签: python soap wsdl zeep

我有WSDL服务,它提供了几个像

这样的链接
http://localhost:8081/View1&Wsdl
...
http://localhost:8081/ViewN&Wsdl

但问题是我无法使用zeep库(2.5.0)处理多个WSDL链接

我的代码:

import zeep

view1_wsdl = 'http://localhost:8081/View1&Wsdl'
client1 = zeep.Client(wsdl=view1_wsdl)
result1 = client1.service.method1()
print(result1) 

view2_wsdl = 'http://localhost:8081/View2&Wsdl'
client2 = zeep.Client(wsdl=view2_wsdl)
result2 = client2.service.method2()
print(result2)

我得到了正确的result1,但是result2有错误:

Traceback (most recent call last):
  File "C:/.../auto_tests/wsdl_check.py", line 17, in <module>
    result2 = client2.service.method2
  File "C:\...\lib\site-packages\zeep\client.py", line 45, in __call__
    self._op_name, args, kwargs)
  File "C:\...\lib\site-packages\zeep\wsdl\bindings\soap.py", line 110, in send
options=options)
  File "C:\...\lib\site-packages\zeep\wsdl\bindings\soap.py", line 68, in _create
    serialized = operation_obj.create(*args, **kwargs)
  File "C:\...\lib\site-packages\zeep\wsdl\definitions.py", line 197, in create
    return self.input.serialize(*args, **kwargs)
  File "C:\...\lib\site-packages\zeep\wsdl\messages\soap.py", line 63, in serialize
    body_value = self.body(*args, **kwargs)
  File "C:\...\lib\site-packages\zeep\xsd\elements\element.py", line 48, in __call__
    instance = self.type(*args, **kwargs)
  File "C:\...\lib\site-packages\zeep\xsd\types\complex.py", line 42, in __call__
    return self._value_class(*args, **kwargs)
  File "C:\...\lib\site-packages\zeep\xsd\valueobjects.py", line 90, in __init__
    items = _process_signature(self._xsd_type, args, kwargs)
  File "C:\...\lib\site-packages\zeep\xsd\valueobjects.py", line 194, in _process_signature
    len(result), num_args))
TypeError: __init__() takes at most 0 positional arguments (1 given)

我该如何处理?

1 个答案:

答案 0 :(得分:0)

问题出在WSDL服务中,而不是zeep lib中。