[Fedora-suds-list] XML literal within an element

Janne Kuuskeri jedi at mobisoft.fi
Wed Jan 13 13:59:26 UTC 2010


Hi,

I have the following pretty simple WSDL:

http://195.165.67.126/XmlUploadWebService/Service.asmx?WSDL


 From that definition I have to use the AddOrder function which takes
one parameter (of type any):


<s:element name="AddOrder">
   <s:complexType>
     <s:sequence>
       <s:element minOccurs="0" maxOccurs="1" name="document">
         <s:complexType mixed="true">
           <s:sequence>
             <s:any/>
           </s:sequence>
         </s:complexType>
       </s:element>
     </s:sequence>
   </s:complexType>
</s:element>


Actually, in that parameter, I have to pass contents of an XML file as a
string. This is the code I'm using for that (as suggested by 
https://fedorahosted.org/suds/wiki/TipsAndTricks#IncludingLiteralXML):

from suds.sax.parser import Parser
p = Parser()
xml = p.parse('order_sample.xml')
client = Client(WSDL_URL)
result = client.service.AddOrder(document=xml)


The problem is that when the parsed xml document is written into soap 
envelope by the SUDS it leaves out the xml namespace binding from the 
root element (the xmlns attribute), and that causes XML validation 
errors on the (3rd party) server. For example:

original XML root element:

<Orderinfo xsi:noNamespaceSchemaLocation="order_schema_v2.xsd" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

the one that SUDS writes within the 'document' element:

<Orderinfo xsi:noNamespaceSchemaLocation="order_schema_v2.xsd">

It also leaves out the <?xml version="1.0" encoding="utf-8"?> from the 
beginning but I'm not sure if this causes any problems.


Is there a simpler way to include a string literal (which won't get 
escaped) in the element? Or some other way to work around this?


Many Thanks



More information about the suds mailing list