I am trying to get a WSDL file from a 3rd party company to work. During parsing zeep fails to properly map some messages and therefore some operations (See details below). From what I can gather is that the main problem seems to be that the xsd:element
for Add
has no targetNamespace
and when resolving zeep prefixes with the targetNamespace
of wsdl:definitions
: https://github.com/mvantellingen/python-zeep/blob/c39197853e681fea773d5f6265b5971cfdf879d7/src/zeep/wsdl/parse.py#L36-L43
I am not sure if this is a bug in zeep or the WSDL, I can neither find a definitive answer in the XML Schema specs, nor in the WSDL ones. What I was able to find is from ws-i (http://www.ws-i.org/Profiles/BasicProfile-1.1.html#Schema_targetNamespace_Structure):
R2105 All xsd:schema elements contained in a wsdl:types element of a DESCRIPTION MUST have a targetNamespace attribute with a valid and non-null value, UNLESS the xsd:schema element has xsd:import and/or xsd:annotation as its only child element(s).
But I do not know if the targetNamespace
from the wsdl:definitions
should get inherited. I'll happily try to code a patch in zeep if you think this is a bug in zeep.
Version: zeep==3.1.0
WSDL: https://apolloner.eu/~apollo13/Calculator.wsdl
Example Script:
from lxml import etree
from zeep import Client
client = Client('https://apolloner.eu/~apollo13/Calculator.wsdl')
node = client.create_message(client.service, 'Add', [], {'a': 3, 'b': 4})
print(etree.tostring(node, pretty_print=True))
Output:
/home/florian/dev/bap/bap-services/.venv/lib/python3.6/site-packages/zeep/wsdl/wsdl.py:338: UserWarning: The wsdl:message for '{http://Example.org}ICalculator_Add_InputMessage' contains an invalid part ('parameters'): invalid xsd type or elements
warnings.warn(str(exc))
/home/florian/dev/bap/bap-services/.venv/lib/python3.6/site-packages/zeep/wsdl/wsdl.py:338: UserWarning: The wsdl:message for '{http://Example.org}ICalculator_Add_OutputMessage' contains an invalid part ('parameters'): invalid xsd type or elements
warnings.warn(str(exc))
/home/florian/dev/bap/bap-services/.venv/lib/python3.6/site-packages/zeep/wsdl/definitions.py:130: UserWarning: The wsdl:operation 'Add' was not found in the wsdl:portType '{http://Example.org}ICalculator'
warnings.warn(str(exc))
Forcing soap:address location to HTTPS
Traceback (most recent call last):
File "/home/florian/dev/bap/bap-services/.venv/lib/python3.6/site-packages/zeep/wsdl/definitions.py", line 149, in get
return self._operations[key]
KeyError: 'Add'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/florian/test.py", line 8, in <module>
client.service, 'Add', [], {'a': 3, 'b': 4})
File "/home/florian/dev/bap/bap-services/.venv/lib/python3.6/site-packages/zeep/client.py", line 131, in create_message
operation_name, args, kwargs, client=self)
File "/home/florian/dev/bap/bap-services/.venv/lib/python3.6/site-packages/zeep/wsdl/bindings/soap.py", line 63, in _create
operation_obj = self.get(operation)
File "/home/florian/dev/bap/bap-services/.venv/lib/python3.6/site-packages/zeep/wsdl/definitions.py", line 151, in get
raise ValueError("No such operation %r on %s" % (key, self.name))
ValueError: No such operation 'Add' on {http://Example.org}DefaultBinding_ICalculator
requires/feedback