Reputation: 111
I've to use a SOAP API for a project. For a specific method I've to send a complex type.
This complex type is declared like that:
<complexType name="specialList">
<sequence>
<element name=data" minOccurs="0"maxOccurs="unbounded">
<complexType>
<simpleContent>
<extension base="string">
<attribute name="key" type="string" use="required"/>
</extension>
</simpleContent>
</complexType>
</element>
</sequence>
</complexType>
This is an example:
<my_action type="specialList">
<data key="myKey">MyValue</data>
<data key="myOtherKey">MyOtherValue</data>
</my_action>
To access to the SOAP API, I use zeep (I tried with suds). The first think I do is retrieve my "specialList".
special_list = client.get_type('ns1:specialList')
my_action = special_list(data=[data_1, data_2])
However I've a problem with the type "data". Indeed this type "data" is not declared. I cannot do a client.get_type("ns1:data").
I tried several time to create an simple element but without success. Do you have an idea how to create this "special" data ?
In advance, thank you.
Sylvain
Upvotes: 3
Views: 3262
Reputation: 368
can you try using AnyObject as indicated in their documentation: http://docs.python-zeep.org/en/master/datastructures.html
so in your code:
from zeep import xsd
special_list = client.get_type('ns1:specialList')
my_action = xsd.AnyObject(special_list, special_list(data=[data_1, data_2]))
Upvotes: 2