[Soap-Python] Multiple nodes with soaplib

Luigi Balduzzi luigi.balduzzi at imavis.com
Wed Sep 8 11:22:13 CEST 2010


Hi. I'm using soaplib (cloned from github)and I have the following problem.
I need to instantiate a node in a XML soap message with this schema:

<xs:complexType name="DNSInformation">
     <xs:sequence>
         <xs:element name="FromDHCP" type="xs:boolean"/>
         <xs:element name="SearchDomain" type="xs:token" minOccurs="0"  
maxOccurs="unbounded"/>
         <!-- ... -->
     </xs:sequence>
</xs:complexType>

So I've written a class:

class DNSInformation(ClassSerializer):
     __namespace__ = 'http://www.onvif.org/ver10/schema'
     _type_info = [
         ("FromDHCP", Boolean.customize(min_occurs = 1, nillable = False)),
         ("SearchDomain", Token.customize(max_occurs = "unbounded",  
nillable = False)),
         # ...
     ]

and a method:

     @rpc(_returns=DNSInformation, _out_variable_name="DNSInformation")
     def GetDNS(self):
         dnsInfo = DNSInformation()
         dnsInfo.FromDHCP = False
         dnsInfo.SearchDomain = "a.b.c"
         # ...
         return dnsInfo

It works fine. But if I'd like more than one SearchDomain, e.g. to  
obtain a message like this:

<s0:DNSInformation>
     <s1:FromDHCP xsi:type="xs:boolean">false</s1:FromDHCP>
     <s1:SearchDomain xsi:type="xs:token">a.b.c</s1:SearchDomain>
     <s1:SearchDomain xsi:type="xs:token">d.e.f</s1:SearchDomain>
</s0:DNSInformation>

how should I do? Is it possible to do this?

Thank you very much!
Luigi



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



More information about the Soap mailing list