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

Improve handling of out-of-order values in a sequence

Open nmaludy opened this issue 6 years ago • 9 comments

The version of zeep (or if you are running master the commit hash/date)

$ pip show zeep
Name: zeep
Version: 2.2.0

The WSDL you are using

https://gist.github.com/nmaludy/5b44b6b8ce6e0151481250521283d684

An example script

https://gist.github.com/nmaludy/e467d0e0d223d3fe0a9e49a424a08826

XML returned from GetRanges() call

https://gist.github.com/nmaludy/0a22fd84d4c41a7ad58e5cd250633059

Note The <inheritAccess> tag comes before the <autoAssign> tag in each range (this is out-of-order with respect to the sequence.

Details

Currently when a server returns values in a <sequence> that are out-of-order zeep throw an exception: https://gist.github.com/nmaludy/d21a6cc266c844298a0465f5d1da47e4

This is fine because technically this is not valid XML according to the WSDL schema. However, when i pass in strict=False to the client i get all of the out-of-order elements dumped into a _raw_elements list on the object. https://gist.github.com/nmaludy/db792168e466e7626ea102569aead04d

Thoughts

When passing strict=False would it be possible to handle out-of-order values in the sequence and assign them to the correct keys in the dict instead of dumping them to _raw_elements?

nmaludy avatar Jul 17 '17 17:07 nmaludy

If this is an AXIS soap server then this seems be a duplicate of #493 Can you confirm that? (It seems only the axis servers are doing this completely wrong)

mvantellingen avatar Jul 23 '17 06:07 mvantellingen

@mvantellingen I don't believe so, this is a Men&Mice IPAM server running on Windows IIS.

nmaludy avatar Jul 24 '17 14:07 nmaludy

Okay. I agree that this should be done better. I'll look into it

mvantellingen avatar Aug 12 '17 08:08 mvantellingen

FYI; I opened up issue #596 before recognizing that it's a duplicate of this and #493. This is biting me really hard with my AXIS server. Feel free to take a look at my ticket for another example of how sorted children tags are causing breakage.

Jitsusama avatar Oct 26 '17 13:10 Jitsusama

@mvantellingen If you can point me in the right direction i really wouldn't mind fixing it. I tried going through the code, but it it's my first time looking at it and i got a little lost in all of the lxml details.

nmaludy avatar Jan 26 '18 22:01 nmaludy

@mvantellingen I'm still interested in helping out here, if you can help point me in the right direction!

nmaludy avatar Apr 16 '18 14:04 nmaludy

You should now be able to use the xsd_ignore_sequence_order flag in the client's settings to parse responses that contain out of order items in a sequence.

dankrause avatar Dec 07 '18 20:12 dankrause

@nmaludy are you sure that your IPAM server is not using Apache Axis library under the hood? I've run into this using some other solution and the xsd_ignore_sequence_order flag works perfectly for me.

saper avatar Oct 05 '21 09:10 saper

You should now be able to use the xsd_ignore_sequence_order flag in the client's settings to parse responses that contain out of order items in a sequence.

This worked perfectly for my issue with the _raw_elements issue.

srichardson-sc avatar Nov 02 '21 14:11 srichardson-sc