Python SUDS - Interrogating the WSDL for MinOccurs and MaxOccurs values
Asked Answered
U

1

0

I would like to interrogate a WSDL using SUDS to get the parameters and attributes of a web service. I'm pretty much down to this one last thing. How do I interrogate the service to find the minOccurs and maxOccurs values of the parameters?

I see there's a property in the suds.xsd.sxbase object called required, but, assuming my starting point is the client object, I don't see path to get to it.

http://jortel.fedorapeople.org/suds/doc/suds.xsd.sxbase-pysrc.html#SchemaObject.required

client = Client(endpoint, username=username, password=password)
client.service[0][method]

How can I find out if a parameter is bound?

Thanks!

Unknown answered 29/2, 2012 at 14:10 Comment(0)
T
0

you can query the factory resolver for the method, and use the children() method to see its parameters.

example, for this method I have my wsdl:

<complexType name="AddAuthorizationRoleRequestType">
   <sequence>
      <element name="_this" type="vim25:ManagedObjectReference" />
      <element name="name" type="xsd:string" />
      <element name="privIds" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
   </sequence>
</complexType>

I can get the attributes via:

>>> a=client.factory.resolver.find("ns0:AddAuthorizationRoleRequestType")
>>> priv_el=a.children()[2][0]
<Element:0x107591a10 name="privIds" type="(u'string', u'http://www.w3.org/2001/XMLSchema')" />
>>> priv_el = a.children()[2][0]
>>> priv_el.max
unbounded
>>> priv_el.min
0

not very elegant, but it works

Toluate answered 6/3, 2012 at 3:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.