[Soap-Python] lxml validation is too restrictive
Dieter Maurer
dieter at handshake.de
Wed Sep 28 07:42:42 CEST 2011
azurIt wrote at 2011-9-27 22:44 +0200:
>lxml is, unfortunately, too restrictive in XML validating :( For example, PHP soap client stopped working at all, lxml is not accepting it's element names:
>
><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="testt" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
><SOAP-ENV:Body>
><ns1:testf>
><first xsi:type="xsd:string">aaa</first>
><second xsi:type="xsd:string">bbb</second>
></ns1:testf>
></SOAP-ENV:Body>
></SOAP-ENV:Envelope>
>
>rpclib error:
><string>:2:0:ERROR:SCHEMASV:SCHEMAV_ELEMENT_CONTENT: Element 'first': This element is not expected. Expected is ( {testt}first ).
>
>
>This is XML generated by SUDS (and accepted by rpclib):
><SOAP-ENV:Envelope xmlns:ns0="testt" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
> <SOAP-ENV:Header/>
> <ns1:Body>
> <ns0:testf>
> <ns0:first>aaa</ns0:first>
> <ns0:second>bbb</ns0:second>
> </ns0:testf>
> </ns1:Body>
></SOAP-ENV:Envelope>
>
>Any ideas how to keep input validating (number of parameters and it's types) but also support at least SUDS + PHP soap client ?
Looks as if your "PHP SOAP client" were faulty.
XML-Schema has an attribute called "elementFormDefault" with values
"unqualified" (the default) and "qualified".
The suds generated XML document as well as the "lxml" error message
suggest that the schema uses "elementFormDefault='qualified'" but
the PHP soap client generates an XML document for
"elementFormDefault='unqualified'".
Again: looking at the generated WSDL will show you who is to blame
("lxml" or your SOAP client).
If it is your SOAP client (as I expect), then you might be able
to tweak the generated WSDL not to use "elementFormDefault='qualified'".
If you are lucky, "lxml" bases its validation on the generated WSDL
and will then accept the XML document from your PHP SOAP client.
--
Dieter
More information about the Soap
mailing list