List all possible values ​​for enumerating SOAP using Python SUDS

I connect to the SUDS client with a SOAP server whose wsdl contains many enumerations, such as:

</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 get sequences that contain elements of these various enumeration types. My need is, given the member variable, I need to know all the possible values ​​of the enumeration. Basically I need a function that takes an instance of one of these enumerations and returns a list of strings that are all possible values.

When I have an instance, do:

print type(foo.enumInstance)

I get:

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

I'm not sure how to get the name simpleType from this, and then get the possible values ​​due to WSDL parsing.

:. simpleType, , , , (x) suds.sax.text.Text

 for l in  client.factory.create('FOOENUMERATION'):
    print l[0]
+3
3

, , , - . - , , suds.sax.text.Text, , factory, , , :

def printEnums(obj,field):
     a=client.factory.create(str(getattr(client.factory.create( str(obj.__class__).replace('suds.sudsobject.','')),field).__class__).replace('suds.sudsobject.',''))
     for i in a:
         print i[0]

:

 printEnums(foo,'enumInstance')

foo factory, foo.enumInstance, factory , , , , - / .

+1

, , , , . , SOAPIPMode, STATIC_MANUAL :

soapIPMode = client.factory.create('SOAPIPMode')
staticManual = soapIPMode['STATIC_MANUAL']

suds.sax.text.Text, .

, :

for i in range(len(soapIPMode):
    process(soapIPMode[i])
+3

See if you can feed into a WSDL to a component ElementTreein Python and use it to get enumerations.

0
source

Source: https://habr.com/ru/post/1749698/


All Articles