mvantellingen / python-zeep

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

Use schema of response to parse the result? #663

Open YAmikep opened 6 years ago

YAmikep commented 6 years ago

Hi

I can't share the WSDL but I attached an example of a response: https://gist.github.com/YAmikep/5916cd11cbd11f83a11b0abdeab24874

The response contains the schema of the result, the WSDL does not contain the schema of the result. Is it possible to make zeep use the schema of the result from the response to parse the response automatically and get python objects?

For now, I only get lxml elements:

{
    'schema': <Schema(location=None, tns=None)>,
    '_value_1': <Element {urn:schemas-microsoft-com:xml-diffgram-v1}diffgram at 0x7ff7abc59148>
}

zeep version: 2.5.0

Thanks

acidjunk commented 6 years ago

I'm not sure i follow completely: but I think my workaround for another problem (#658 ) almost does what you ask: https://github.com/acidjunk/python-zeep/commit/542bfec297bf520ebcd78659e7b1ee6340f98650

It parses the result and just returns it as a python object (you should probably remove the XSD signature check)

CoLoR58 commented 6 years ago

I have the same problem. Example:

from zeep import Client
from datetime import datetime, timedelta
client = Client("http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx?wsdl")
print(client.service.Ruonia((datetime.now() - timedelta(days=30)),datetime.now()))

result:

{ 'schema': <Schema(location=None, tns=None)>, '_value_1': <Element {urn:schemas-microsoft-com:xml-diffgram-v1}diffgram at 0x3462a30> }

tr0yspradling commented 5 years ago

I'm having this issue as well.

{ 'schema': <Schema(location=None, tns=None)>, '_value_1': <Element {urn:schemas-microsoft-com:xml-diffgram-v1}diffgram at 0x7f3c877003c8> }

Okay, so I've discovered this error only occurs (for me, at least) when the SOAP API has nothing to return. I was able to retrieve my data when there was something to actually retrieve.

{
    'schema': <Schema(location=None, tns=None)>,
    '_value_1': {
        '_value_1': [
            {
                'Ledgers': {
...

Sorry I'm unable to debug any further.