WSDL parsing problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nick Caldwell

    #1

    WSDL parsing problem


    Y'all,

    Problem: Reading complex data types returned from WSDL

    I'll present this in 3 sections.

    1. Output of WSDL parser on Google API
    2. Output of WSDL parser on Custom API
    3. WSDL parser code

    1. Output of WSDL parser on Google API
    So far I have a very simple WSDL reader which gathers the commnads and
    arguments of the WSDL. For instance, running against the google API
    generates:
    Commands: [u'doGoogleSearc h', u'doGetCachedPa ge',
    u'doSpellingSug gestion']

    Arguments for "doGoogleSearch ":
    key (u'http://www.w3.org/2001/XMLSchema', u'string')
    q (u'http://www.w3.org/2001/XMLSchema', u'string')
    start (u'http://www.w3.org/2001/XMLSchema', u'int')
    maxResults (u'http://www.w3.org/2001/XMLSchema', u'int')
    filter (u'http://www.w3.org/2001/XMLSchema', u'boolean')
    restrict (u'http://www.w3.org/2001/XMLSchema', u'string')
    safeSearch (u'http://www.w3.org/2001/XMLSchema', u'boolean')
    lr (u'http://www.w3.org/2001/XMLSchema', u'string')
    ie (u'http://www.w3.org/2001/XMLSchema', u'string')
    oe (u'http://www.w3.org/2001/XMLSchema', u'string')

    With this it is easy to create a command and send it the proper value
    types. You still have to know what each does, but the type is
    obvious.


    2. Output of WSDL parser on Custom API
    When I run this against my company's custom API, though, I see the
    comnmands fine:

    Commands: [u'getCustomerIn formation']

    But the argument names and types look like:
    getCustomerInfo rmationRequest
    (u'java:com.pro ductname.produc tversion.soap', u'ge
    tCustomerInform ation')

    Now, according to my developers this is because they treat each api
    call like a separate document which returns several values, whereas
    the google API treats each as a separate data type (string).

    The WSDL would look like this:
    <xsd:complexTyp e name="CustomerI nfo">
    <xsd:sequence >
    <xsd:element type="xsd:strin g" name="email" minOccurs="1"
    maxOccurs="1" nillable="true" />
    <xsd:element type="xsd:strin g" name="firstName " minOccurs="1"
    maxOccurs="1" nillable="true" />
    <xsd:element type="xsd:strin g" name="lastName" minOccurs="1"
    <xsd:element type="xsd:strin g" name="phoneNumb er" minOccurs="1"
    maxOccurs="1" nillable="true" />
    </xsd:sequence>
    </xsd:complexType >

    Can I somehow parse the response from the WSDL to get at the atomic
    data types? The goal is to do this programmaticall y to provide a GUI
    front end for the APIs for testing.

    3. WSDL reader
    #!/usr/bin/env python
    #http level debugging
    import httplib
    httplib.HTTPCon nection.debugle vel = 1

    from SOAPpy import WSDL
    server = WSDL.Proxy('d:/googleapi/GoogleSearch.ws dl')
    print server.methods. keys()
    callInfo = server.methods['doGoogleSearch ']
    for arg in callInfo.inpara ms:
    print arg.name.ljust( 15), arg.type

    Any help at all would be appreciated.

    Sincerely,

    Nick



Working...