[Soap-Python] List of objects

Burak Arslan burak.arslan at arskom.com.tr
Mon Aug 30 21:07:03 CEST 2010


 On 08/30/10 08:32, Minh Luu wrote:
> Hi,
>
> I am new to soaplib. I would like to setup a service that would accept the following XML
>
> <contacts>
>   <contact>
>     <name>Allan</name>
>     <title>MR</title>
>   </contact>
>   <contact>
>     <name>Julie</name>
>     <title>MS</title>
>   </contact>
> </contacts>
>
> I have try this but it didn't work. I get the error of 'NoneType object has no attribute from_xml
>
> class Contact(ClassSerializer):
>     class types:
>         name = String
>         title = String
>
> class Contacts(ClassSerializer):
>     class types:
>         contact = Array(Contact)
>
>

what version of soaplib is it?

the sample xml does not contain a method call, nor namespace
qualifications. soaplib won't accept that *exact* message inside a soap
envelope. you need to define some methods.

here's what i'd do (with 0.9.x, minus imports)

class Contact(ClassSerializer):
        name = String
        title = String

class Contacts(ClassSerializer):
        contact = Array(Contact)

class ServiceDefinition(soaplib.service.DefinitionBase):
    @rpc(_returns=Array(Contact))
    def get_contacts(self)
        c1 = Contact()
        c1.name = 'punk'
        c1.title = 'ceo'

        c2 = Contact()
        c2.name = 'nerd'
        c2.title = 'cto'
        return [c1,c2]


look here for an example about what to do with that service:
http://github.com/arskom/soaplib/blob/master/examples/helloworld.py


hth
burak






More information about the Soap mailing list