Listing all possible values for SOAP enumeration with Python SUDS

Posted by bdk on Stack Overflow See other posts from Stack Overflow or by bdk
Published on 2010-06-12T03:02:41Z Indexed on 2010/06/12 3:13 UTC
Read the original article Hit count: 402

Filed under:
|
|
|

I'm connecting with a SUDS client to a SOAP Server whose wsdl contains manu enumerations like the following:

</simpleType>
  <simpleType name="FOOENUMERATION">
  <restriction base="xsd:string">
   <enumeration value="ALPHA"><!-- enum const = 0 -->
   <enumeration value="BETA"/><!-- enum const = 1 -->
   <enumeration value="GAMMA"/><!-- enum const = 2 -->
   <enumeration value="DELTA"/><!-- enum const = 3 -->
  </restriction>
</simpleType>

In my client I am receiving sequences which contain elements of these various enumeration types. My need is that given a member variable, I need to know all possible enumeration values. Basically I need a function which takes an instance of one of these enums and returns a list of strings which are all the possible values.

When I have an instance, running:

print type(foo.enumInstance)

I get:

<class 'suds.sax.text.Text'>

I'm not sure how to get the actual simpleType name from this, and then get the possible values from that short of parsing the WSDL myself.

© Stack Overflow or respective owner

Related posts about python

Related posts about soap