On 11/18/2009 02:44 PM, Dan Sommers wrote:
Greetings,
Hey Dan :)
I'm calling a web service whose return value is a complex type, and I'm
trying to recover the "original" XML from the SOAP response rather than
the python object (so that I can store that XML in my database for
further analysis later). I thumbed through the archives, and found
these:
https://www.redhat.com/archives/fedora-suds-list/2009-November/msg00021.html,
https://www.redhat.com/archives/fedora-suds-list/2009-September/msg00009....,
https://www.redhat.com/archives/fedora-suds-list/2009-August/msg00022.html,
https://www.redhat.com/archives/fedora-suds-list/2009-August/msg00022.html
but no real solution.
I can recover something close by calling last_received method of the
client, or equivalently by setting the retxml option of the client, but
I'm having an awful time fixing up all of the namespaces and getting rid
of the elements with xsi:nil="true" attributes.
Both last_received() and using setting the 'retxml' option results in giving you
access to
the sax parsed XML returned by the server. The suds.sax.element.Element object can be
easily converted to a string for storage by:
d = client.last_received()
s = str(d)
client.set_options(retxml=True)
d = client.service.foo()
s = str(d)
but, I'm assuming that is somehow not what you're looking for. Can you be more
specific
about how this does not meet you needs? Is it because the str() of the DOM tree is a
reconstruction of the string XML and not the raw string XML? There should be almost no
difference them. Also, won't you have the same problems with:
<snip>
I'm having an awful time fixing up all of the namespaces and
getting rid
of the elements with xsi:nil="true" attributes.
</snip>
even if you had the raw string XML?
Is there a (simple?) solution to this issue? I can provide WSDL and an
actual SOAP response if that would help, but I think that this is a
generic issue (and I'd certainly like to solve it that way).
Generic, yes. That is where the two methods for getting the returned XML you mentioned
above came from.
It would seem that if suds can parse WSDL and SOAP messages, then there
should be enough infrastructure to recover the XML from the server. (In
fact, it seems that suds almost has to recover that XML in order to
build the python object that it does.) Or maybe it's just easy for me
to say that because I'm relatively new at SOAP. ;-)
The exact XML (stream) returned by the server is consumed by the sax parser (inline) and
isn't really available. To capture it, I would have to read the entire document into
memory then sax parse the string.
Thanks,
Dan
_______________________________________________
fedora-suds-list mailing list
fedora-suds-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/fedora-suds-list