Hi guys,
I'm getting a strange bug using suds on this service http://cdsws.u-strasbg.fr/axis/services/Sesame?wsdl.
My code is something like:
proxy = ServiceProxy(Simbad.WSDL) print proxy.sesame ('M51', 'x')
and the result is something like:
<?xml version="1.0"encoding="UTF-8"?><Sesame xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance%22xsi:noNamespaceSchemaLocation=%2...<!-- Q28920 --><target>UFO</target><Resolver name="Simbad"><INFO>Zero (0) answers</INFO><INFO>*** This identifier is not present in the database: NAME UFO</INFO></Resolver><Resolver name="VizieR"><INFO>Zero (0) answers</INFO><INFO>No table found for: UFO</INFO></Resolver><Resolver name="Ned"><INFO>Zero (0) answers</INFO><INFO>!***Connection to Ned crashed</INFO></Resolver></Sesame>
Here is the problem: Note that there are no spaces between version and encoding attributes on <?xml and later on Sesame namespace declaration there are no spaces between two xsi declarations. This make this XML not well formed and no parser accept to digest this.
When I turn debug on, I see this:
2008-05-15 03:38:16,747 {12055} (serviceproxy.py, 267) [DEBUG] http succeeded: <?xml version="1.0" encoding="UTF-8"?>soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"soapenv:Bodyns1:sesameResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:Sesame"<return xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?> <Sesame xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance%22; xsi:noNamespaceSchemaLocation="http://vizier.u-strasbg.fr/xml/sesame_2.xsd%22%3E; <!-- Q28920 --> <target>UFO</target> <Resolver name="Simbad"> <INFO>Zero (0) answers</INFO> <INFO>*** This identifier is not present in the database: NAME UFO</INFO> </Resolver> <Resolver name="VizieR"> <INFO>Zero (0) answers</INFO> <INFO>No table found for: UFO</INFO> </Resolver> <Resolver name="Ned"> <INFO>Zero (0) answers</INFO> <INFO>!***Connection to Ned crashed </INFO> </Resolver> </Sesame> </return></ns1:sesameResponse></soapenv:Body></soapenv:Envelope>
From this, seems that somewhere in the unmarshaller, the \n are
replaced and all the lines are stripped, making the errors cited above.
While I was writing this I found that on sax.py:Handler.characters there is a strip call! If I remove that strip, everything goes well! Is that strip really necessary or is this a bug?
Thanks a lot,
-- Paulo Henrique
Hey Paulo,
Thanks for your interest in Suds. I'm glad to hear you find it helpful.
The strip() was intended to mitigate the annoying text nodes produced by "pretty" formatted XML. However, in reality, soap servers don't format the XML and, as you point out, having the strip() causes problems.
Great catch! I'll remove the strip() on trunk asap and post a notice on the mailing list.
Thanks again,
Regards,
Jeff
Paulo Henrique Silva wrote:
Hi guys,
I'm getting a strange bug using suds on this service http://cdsws.u-strasbg.fr/axis/services/Sesame?wsdl.
My code is something like:
proxy = ServiceProxy(Simbad.WSDL) print proxy.sesame ('M51', 'x')
and the result is something like:
<?xml version="1.0"encoding="UTF-8"?><Sesame
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance%22xsi:noNamespaceSchemaLocation=%2...<!-- Q28920 --><target>UFO</target><Resolver name="Simbad"><INFO>Zero (0) answers</INFO><INFO>*** This identifier is not present in the database: NAME UFO</INFO></Resolver><Resolver name="VizieR"><INFO>Zero (0) answers</INFO><INFO>No table found for: UFO</INFO></Resolver><Resolver name="Ned"><INFO>Zero (0) answers</INFO><INFO>!***Connection to Ned crashed</INFO></Resolver></Sesame>
Here is the problem: Note that there are no spaces between version and encoding attributes on <?xml and later on Sesame namespace declaration there are no spaces between two xsi declarations. This make this XML not well formed and no parser accept to digest this.
When I turn debug on, I see this:
2008-05-15 03:38:16,747 {12055} (serviceproxy.py, 267) [DEBUG] http succeeded:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance%22%3Esoapenv:Bodyns1:sesameResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:Sesame"<return xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?> <Sesame xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance%22; xsi:noNamespaceSchemaLocation="http://vizier.u-strasbg.fr/xml/sesame_2.xsd%22%3E; <!-- Q28920 --> <target>UFO</target> <Resolver name="Simbad"> <INFO>Zero (0) answers</INFO> <INFO>*** This identifier is not present in the database: NAME UFO</INFO> </Resolver> <Resolver name="VizieR"> <INFO>Zero (0) answers</INFO> <INFO>No table found for: UFO</INFO> </Resolver> <Resolver name="Ned"> <INFO>Zero (0) answers</INFO> <INFO>!***Connection to Ned crashed </INFO> </Resolver> </Sesame> </return></ns1:sesameResponse></soapenv:Body></soapenv:Envelope>
From this, seems that somewhere in the unmarshaller, the \n are
replaced and all the lines are stripped, making the errors cited above.
While I was writing this I found that on sax.py:Handler.characters there is a strip call! If I remove that strip, everything goes well! Is that strip really necessary or is this a bug?
Thanks a lot,
-- Paulo Henrique
fedora-suds-list mailing list fedora-suds-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-suds-list