python - Attributes and values in suds -


i have troubles complextype in wsdl. here part of wsdl:

<xs:element name="params" nillable="true">                        <xs:complextype>                                                                                <xs:sequence>                                                                                   <xs:element name="param" minoccurs="0" maxoccurs="unbounded">                 <xs:complextype>                                                  <xs:simplecontent>                                                <xs:extension base="xs:string">                                   <xs:attribute name="name" type="xs:string"/>                         </xs:extension>                                           </xs:simplecontent>                                       </xs:complextype>                                         </xs:element>                                                                           </xs:sequence>                                                                          </xs:complextype>                                                                       </xs:element> 

result fields in soap-req must like:

<ns0:params>     <ns0:param ns1:name="name1">val1</ns1:param>     <ns0:param ns1:name="name1">val1</ns1:param> </ns0:params> 

suds give me next type:

>>> client.factory.create("payment.params.param")   (param){       _name = ""   } 

if set _name, suds generate xml:

<ns0:params>     <ns0:param name="name1"/>     <ns0:param name="name2"/> </ns0:params> 

so, can set attribute name "param", how can set value?

you have create 'param' element without attributes , use marshalled plugin add 'name' attribute:

# disclaimer: not tested! suds.plugin import messageplugin  class myplugin(messageplugin):     def marshalled(self, context):         body = context.envelope.getchild('body')         params = body.getchild('fix_this_path').getchild('params')           foo = params[0]         foo.set('name', 'name1')  client = client(url, plugins=[myplugin()]) ... params = client.factory.create("payment.params") params.param = "val1" 

more info here: https://fedorahosted.org/suds/wiki/documentation#messageplugin

hope helps


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -