Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aleksejs-fomins opened this issue Apr 12, 2024 · 0 comments
Open

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

aleksejs-fomins opened this issue Apr 12, 2024 · 0 comments

Comments

@aleksejs-fomins
Copy link

aleksejs-fomins commented Apr 12, 2024

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.

<user classname="user" id="5"> <active>true</active> <project classname="project" id="12345"/> <order projectid="12345" classname="order" id="3"/> ...

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), 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))
@aleksejs-fomins aleksejs-fomins changed the title Occasional XML Some XML elements do not have attributes (inconsistently) Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant