Reputation: 13
I need to integrate to some messy SOAP endpoints to retrieve data, and am stuck in generating the request message. Generating request messages, and talk to the target application works for most of the functions, but for some functions (as said: messy) I need to include an XML schema as an element in the request message. The XML schema needs to be inserted at an element defined as a xs:any type.
When inspecting the wsdl using python -mzeep, the following output is shown (DataSet
is the element I need to insert the schema into):
ns1:FillDataSet(asID: xsd:string, asFromCompCode:, ..... , DataSet: {_value_1: ANY})
I did not find a way to insert an schema in the Zeep library (quite obvious why, but I need it :( ), using the xsd or other classes, can somebody help me with this? I think I need to instantiate the any object holding the XML schema separately, but do not know how ..
Upvotes: 0
Views: 1761
Reputation: 154
Types you can pass to Any
field:
lxml.etree._Element
builtins.dict
zeep.xsd.valueobjects.AnyObject
With first option you can pass anything that was parsed by lxml directly (eg by etree.fromstring
).
{'DataSet': lxml_elem1}
2nd option should look like: {'_value_1': ANY[]}
, where ANY
is either lxml element or AnyObject. It is used for python-zeep nested types
3rd option used when you want to construct object using python-zeep factory and pass it to field with Any type (more details here). You can use Any() as base type here eg
{'DataSet': AnyObject(Any(), [lxml_elem1, lxml_elem2])
Below is equivalent expression:
{'DataSet': {'_value_1': [lxml_elem1, AnyObj2]}}
Check maxOccurs
in any
element definition, if it's not set (equals to 1 by default) - only first element from list will be used for xml generation
Upvotes: 1