mvantellingen / python-zeep

A Python SOAP client
http://docs.python-zeep.org
Other
1.87k stars 578 forks source link

Some XML elements do not have attributes (inconsistently) #1415

Open aleksejs-fomins opened 2 months ago

aleksejs-fomins commented 2 months ago

Hi, I'm new to Zeep, and I am updating some legacy code that is using it. I have found that the parsed Zeep dictionaries differ significantly from the raw XML response. Unfortunately, I cannot post the data here because it is sensitive. But I can post the code. The code is the same as the one for the other issue I have posted, but the problem is different. I understand that this is likely difficult to debug, but perhaps just from seeing my code you can tell that I am doing something wrong?

Zeep version is 4.2.1, Python 3.10.9.

Zeep seems to occasionally fail to find attribites inside of nested XML. Specifically, there seems to be a problem with the XML element project in below.

`

true ... ` In my test, this happened to ~10 out of 300 user queries that I did. The raw XML for those users contained the information as shown above, same as for other users. The parsed dictionary key for project contained a whole bunch of extra key-value pairs that are not part of XML (see my other [issue](https://github.com/mvantellingen/python-zeep/issues/1414)), but did not contain the fields `classname` and `id` for those users. Again, this script works for most users. Further, I have tried SUDS with the same query, and this specific query works for all users, so it is unlikely to be a problem of the raw XML. I would appreciate any advices. Below I show my code I use the following to obtain the raw XML and the parsed data, by changing the raw_response flag. ``` client = zeep.Client(wsdl) with client.settings(strict=False, raw_response=raw_response): ret = client.service.read(query) ``` For raw response, I extract `ret.content`. For parsed response, I convert everything to dictionaries via ``` dict(zeep.helpers.serialize_object(ret, target_cls=dict)) ```