9

I am calling methods in a SOAP API from my Python code using suds. I am trying to programmatically determine what information to send as parameters to the methods in the API. One of the WSDLs I'm looking at is here.

There is a method defined in that WSDL with the following signature:

GetActiveDirectoryObjects(FilterOptions filterOptions)

I can use suds to create a client for this WSDL and then I can use client.factory.create() method as follows:

from suds.client import Client
client = Client('https://controlpanel.msoutlookonline.net/WebServices/ActiveDirectory/ActiveDirectoryService.asmx?WSDL')
client.factory.create('FilterOptions')

output is:

(FilterOptions){
   AttributesToRead =
      (ArrayOfString){
         string[] = <empty>
      }
   SortBy = None
   SortDirection =
      (SortDirection){
         value = None
      }
   ResultSize = None
   Filter =
      (AndOperation){
         ExtensionData = None
      }
   SearchBase = None
 }

What I can't figure out is how I can determine, using suds, whether 'SortBy' wants to be assigned a string or an int or a boolean, or what. I know 'AttributesToRead' wants to be assigned an 'ArrayOfString'. I know 'SortDirection' wants to be assigned an object of type 'SortDirection'. But what about SearchBase? ResultSize? How can my program determine whether the auto-generated form should contain a field that will validate for an int or for a boolean or for a string?

Looking at the WSDL XML I see the following:

<s:complexType name="FilterOptions">
    <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="AttributesToRead" type="tns:ArrayOfString"/>
        <s:element minOccurs="0" maxOccurs="1" name="SortBy" type="s:string"/>
        <s:element minOccurs="1" maxOccurs="1" name="SortDirection" type="tns:SortDirection"/>
        <s:element minOccurs="0" maxOccurs="1" name="ResultSize" type="s:string"/>
        <s:element minOccurs="0" maxOccurs="1" name="Filter" type="tns:AndOperation"/>
        <s:element minOccurs="0" maxOccurs="1" name="SearchBase" type="s:string"/>
    </s:sequence>
</s:complexType>

So I know from reading the XML manually that 'SortBy' wants to be assigned a string -- but how can I figure this out programmatically using suds? I don't want to spend days writing code that parses the XML to figure this out when the people who wrote suds already followed the SOAP specs closely -- but what is the secret to getting suds to tell me that 'SortBy' should be of type 'string'?

dda
  • 6,030
  • 2
  • 25
  • 34
tadasajon
  • 14,276
  • 29
  • 92
  • 144
  • 2
    I think http://stackoverflow.com/questions/9500626/python-suds-interrogating-the-wsdl-for-minoccurs-and-maxoccurs-values has the answer. priv_el.name priv_el.type – bernhard_s Mar 20 '13 at 19:36

0 Answers0