This is basically the same question as here:
creating any object with python zeep
I am working on a Python script that includes SOAP API calls. Mostly these are working but I am having a problem with one. I have SOAPUI example working, it looks like this:
soap ui that works
<!-- language: lang-xml -->
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="Urn:ApiService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Header/>
<soapenv:Body>
<urn:getAllOperationalDevices soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<in0 xsi:type="api:ResourceIdentityInfo" xmlns:api="http://api.common.configmgr.powerup.com">
<resourceKey xsi:type="soapenc:string">0a053ebeddf9e53f53e125d364010000</resourceKey>
<resourceName xsi:type="soapenc:string">Customer1</resourceName>
<resourceType xsi:type="soapenc:string">NETWORK</resourceType>
</in0>
<in1 xsi:type="fil:FilterInfo" xmlns:fil="http://filter.api.common.configmgr.powerup.com">
<filterComponents>
<FilterExpressionInfo xsi:type="ns:FilterExpressionInfo" xmlns:ns="http://filter.api.common.configmgr.powerup.com">
<attributeName>managementIpAddress</attributeName>
<value xsi:type="xsd:string">10.10.10.10</value>
<operator>==</operator>
</FilterExpressionInfo>
</filterComponents>
</in1>
</urn:getAllOperationalDevices>
</soapenv:Body>
</soapenv:Envelope>
I see in the WSDL that the filter value is AnyType:
And I see in the zeep documentation that there is special handling for AnyType, with the example I copied in my code below:
zeep documentation example of AnyType
client = Client('http://my-entrprisy-endpoint.com')
value = xsd.AnyObject(xsd.String(), 'foobar')
client.service.submit_something(user_id=1, my_string=value)
My attempt to create this request in zeep looks like:
my python that returns error
print("API: getAllOperationalDevices")
in0 = {'resourceKey':nkey,'resourceName':nname,'resourceType':ntype}
value = xsd.AnyObject(xsd.String(),dmgmtip)
filter = {'attributeName':'managementIpAddress','value':value,'operator':'=='}
feInfo = {'FilterExpressionInfo' : [filter]}
filComp = {'filterComponents' : feInfo}
result = client.service.getAllOperationalDevices(in0,filComp)
I think this should be pretty close but I get the error below:
my python error
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/zeep/xsd/elements/any.py", line 181, in validate
raise exceptions.ValidationError("Missing element for Any")
My attempts to use zeep's client.service.get_element and client.service.get_type are failing because the namespace is not recognized, seems like it should be 'urn:getAllOperationalDevices' but evidently it is not.
If anyone can give me a nudge in the right direction I'd appreciate it!