python-zeep
python-zeep copied to clipboard
Client picks up value from args instead of kwargs
- Zeep version: 3.4.0
- WSDL: https://gist.githubusercontent.com/ritzmann/3f7bf46626bf75330967cb208dc6af06/raw/c3765e1c379f5f5a3d56391c4b1e75dfac57f5d1/test.wsdl
- Script:
from lxml import etree
from zeep import Client
client = Client('https://gist.githubusercontent.com/ritzmann/3f7bf46626bf75330967cb208dc6af06/raw/c3765e1c379f5f5a3d56391c4b1e75dfac57f5d1/test.wsdl')
kwargs = { 'MyElement1': 'value1', 'MyElement2': 'value2' }
node = client.create_message(
client.service, 'myOperation', None, **kwargs)
print(etree.tostring(node, pretty_print=True).decode())
args = [ 'args value1' ]
node = client.create_message(
client.service, 'myOperation', *args, **kwargs)
print(etree.tostring(node, pretty_print=True).decode())
Output:
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body>
<ns0:myRequest xmlns:ns0="http://example.test/">
<MyElement2>value2</MyElement2>
</ns0:myRequest>
</soap-env:Body>
</soap-env:Envelope>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body>
<ns0:myRequest xmlns:ns0="http://example.test/">
<MyElement1>args value1</MyElement1>
<MyElement2>value2</MyElement2>
</ns0:myRequest>
</soap-env:Body>
</soap-env:Envelope>
In the first section of the script, you can see that value1 for MyElement1 is never picked up by the generated message. The second section demonstrates that MyElement1 is populated from args instead of kwargs. The WSDL says:
<xsd:sequence>
<xsd:element name="MyElement1" type="xsd:string" minOccurs="0"/>
<xsd:element name="MyElement2" type="xsd:string"/>
</xsd:sequence>
So I would expect that both MyElement1 and MyElement2 would be populated from kwargs.
Note that the XSD may seem slightly convoluted but I took it from a more complex WSDL and removed all elements that are not necessary for this bug report.
possibly related: https://github.com/mvantellingen/python-zeep/issues/1395