How do i add a new object with suds?
Posted
by Jerome
on Stack Overflow
See other posts from Stack Overflow
or by Jerome
Published on 2010-05-29T01:08:47Z
Indexed on
2010/05/29
1:12 UTC
Read the original article
Hit count: 277
I'm trying to use suds but have so far been unsuccessful at figuring this out. Hopefully it's something simple that i'm missing. Any help would be highly appreciated.
This is supposed to be the raw soap message that i need to achieve:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:api="http://api.service.apimember.soapservice.com/">
<soapenv:Header/>
<soapenv:Body>
<api:insertOrUpdateMemberByObj>
<token>t67GFCygjhkjyUy8y9hkjhlkjhuii</token>
<member>
<dynContent>
<entry>
<key>FIRSTNAME</key>
<value>hhhhbbbbb</value>
</entry>
</dynContent>
<email>[email protected]</email>
</member>
</api:insertOrUpdateMemberByObj>
</soapenv:Body>
</soapenv:Envelope>
So i use suds to create the member object:
member = client.factory.create('member')
produces:
(apiMember){
attributes =
(attributes){
entry[] = <empty>
}
}
How exactly do i append an 'entry'?
I try this:
member.attributes.entry.append({'key':'FIRSTNAME','value':'test'})
and that produces this:
(apiMember){
attributes =
(attributes){
entry[] =
{
value = "test"
key = "FIRSTNAME"
},
}
}
However, what i actually need is:
(apiMember){
attributes =
(attributes){
entry[] =
(entry) {
value = "test"
key = "FIRSTNAME"
},
}
}
How do i achieve this?
© Stack Overflow or respective owner