python-zeep icon indicating copy to clipboard operation
python-zeep copied to clipboard

Client picks up value from args instead of kwargs

Open ritzmann opened this issue 5 years ago • 1 comments

  1. Zeep version: 3.4.0
  2. WSDL: https://gist.githubusercontent.com/ritzmann/3f7bf46626bf75330967cb208dc6af06/raw/c3765e1c379f5f5a3d56391c4b1e75dfac57f5d1/test.wsdl
  3. 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.

ritzmann avatar Feb 28 '20 14:02 ritzmann

possibly related: https://github.com/mvantellingen/python-zeep/issues/1395

giuliohome avatar Oct 20 '23 19:10 giuliohome