title: Introspecting a WSDL with Python Zeep
body: <p>I am attempting to use Zeep to describe the operations and types in a given WSDL, so that a program knows the operation names, their parameter names, the parameter types, and parameter attributes. </p>
  
  <p>This info will be used to dynamically generate a UI for a given WSDL.</p>
  
  <p>What I have got so far is just the string representations of the operations and types. Using code similar to what is found in <a href="https://stackoverflow.com/questions/44885439/parse-wsdl-with-zeep">this answer</a>.</p>
  
  <p>Here's an example:</p>
  
  <pre><code>from zeep import Client
  import operator
  
  wsdl = 'http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl'
  client = Client(wsdl)
  
  # get each operation signature
  for service in client.wsdl.services.values():
      print("service:", service.name)
      for port in service.ports.values():
          operations = sorted(
              port.binding._operations.values(),
              key=operator.attrgetter('name'))
  
          for operation in operations:
              print("method :", operation.name)
              print("  input :", operation.input.signature())
              print()
      print()
  
  # get a specific type signature by name
  complextype = client.get_type('ns0:CartGetRequest')
  print(complextype.name)
  print(complextype.signature())
  </code></pre>
  
  <p>This gives an output like the following (shortened for brevity)</p>
  
  <pre><code>[...]
  
  method : CartCreate
    input : MarketplaceDomain: xsd:string, AWSAccessKeyId: xsd:string, AssociateTag: xsd:string, Validate: xsd:string, XMLEscaping: xsd:string, Shared: ns0:CartCreateRequest, Request: ns0:CartCreateRequest[]
  
  method : CartGet
    input : MarketplaceDomain: xsd:string, AWSAccessKeyId: xsd:string, AssociateTag: xsd:string, Validate: xsd:string, XMLEscaping: xsd:string, Shared: ns0:CartGetRequest, Request: ns0:CartGetRequest[]
  
  [...]
  
  
  CartGetRequest
  {http://webservices.amazon.com/AWSECommerceService/2011-08-01}CartGetRequest(CartId: xsd:string, HMAC: xsd:string, MergeCart: xsd:string, ResponseGroup: xsd:string[])
  </code></pre>
  
  <p>The string representations returned by .signature() have  the names and types, but I don't know how to parse them out individually. I have tried looping over each objects attrs with dir() as well, and they don't contain this info. It seems to be nested much deeper.</p>
  
  <p>I could parse the string representations themselves, but then I am also missing whether or not the parameter is optional (more specifically, if it has the attribute minOccurs=0 </p>
  
  <p>It seems like <a href="http://www.diveintopython.net/soap_web_services/introspection.html" rel="noreferrer">SOAPpy actually has this functionality</a>, but isn't maintained anymore.</p>
  
  <p>So is there a way to introspect a WSDL with zeep that provides granular information about each operation, it's parameter names, types, and attributes similar to the SOAPpy implementation? Or should I parse the signature, or alternatively, parse the WSDL with a regular XML parser.</p>