SOAPpy and ArrayOfString

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

    #1

    SOAPpy and ArrayOfString

    Hello all,

    I am trying to use a web services API with Python and SOAPpy as a
    client. Some of the method paramters in this web service's WSDL are
    asking for an "ArrayOfStr ing" type. Here is my code so far:

    #!/usr/bin/python

    from SOAPpy import WSDL

    wsdlFile =
    'http://localhost:8080/axis/services/USD_R11_WebServ ice?WSDL'

    server = WSDL.Proxy(wsdl File)

    server.soapprox y.config.dumpSO APOut = 1
    server.soapprox y.config.dumpSO APIn = 1

    SID = server.login('s rvcdesk', 'xxxxxxxx')

    contacts = server.doSelect (SID, 'cnt', "userid = 'abeju01'", 1,
    ['last_name', 'first_name', 'userid'])


    I tried using a simple Python list for the argument that wants
    "ArrayOfString" . Python generates the following XML for the last
    argument of the "doSelect" command above:

    <v5 SOAP-ENC:arrayType=" xsd:string[3]" xsi:type="SOAP-ENC:Array">
    <item>last_name </item>
    <item>first_nam e</item>
    <item>userid</item>
    </v5>


    The web service does not like this at all and returns the following
    error:

    SOAPpy.Types.fa ultType: <Fault soapenv:Server. userException:
    org.xml.sax.SAX Exception: Bad types (class [Ljava.lang.Obje ct; -class
    usdjws65.ArrayO fString): >


    I know in Perl I had to do some special gyrations to pass the right
    structue for ArrayOfString to this same web service. Is there any way
    to force a type in Python or any other ideas on how to do this?

  • icius

    #2
    Re: SOAPpy and ArrayOfString

    Figured it out. This works:


    #!/usr/bin/python

    import SOAPpy

    wsdlFile =
    'http://localhost:8080/axis/services/USD_R11_WebServ ice?WSDL'

    server = SOAPpy.WSDL.Pro xy(wsdlFile)

    server.soapprox y.config.dumpSO APOut = 1
    server.soapprox y.config.dumpSO APIn = 1

    SID = server.login('s rvcdesk', 'xxxxxxxxx')

    attr = SOAPpy.structTy pe()
    attr._addItem(' string', 'userid')
    attr._addItem(' string', 'last_name')
    attr._addItem(' string', 'first_name')

    contacts = server.doSelect (SID, 'cnt', "userid = 'srvcdesk'", 1, attr)

    print contacts

    server.logout(S ID)


    The XML generated is very similar, but my web service seems to like
    this for some reason...weird.



    icius wrote:
    Hello all,
    >
    I am trying to use a web services API with Python and SOAPpy as a
    client. Some of the method paramters in this web service's WSDL are
    asking for an "ArrayOfStr ing" type. Here is my code so far:
    >
    #!/usr/bin/python
    >
    from SOAPpy import WSDL
    >
    wsdlFile =
    'http://localhost:8080/axis/services/USD_R11_WebServ ice?WSDL'
    >
    server = WSDL.Proxy(wsdl File)
    >
    server.soapprox y.config.dumpSO APOut = 1
    server.soapprox y.config.dumpSO APIn = 1
    >
    SID = server.login('s rvcdesk', 'xxxxxxxx')
    >
    contacts = server.doSelect (SID, 'cnt', "userid = 'abeju01'", 1,
    ['last_name', 'first_name', 'userid'])
    >
    >
    I tried using a simple Python list for the argument that wants
    "ArrayOfString" . Python generates the following XML for the last
    argument of the "doSelect" command above:
    >
    <v5 SOAP-ENC:arrayType=" xsd:string[3]" xsi:type="SOAP-ENC:Array">
    <item>last_name </item>
    <item>first_nam e</item>
    <item>userid</item>
    </v5>
    >
    >
    The web service does not like this at all and returns the following
    error:
    >
    SOAPpy.Types.fa ultType: <Fault soapenv:Server. userException:
    org.xml.sax.SAX Exception: Bad types (class [Ljava.lang.Obje ct; -class
    usdjws65.ArrayO fString): >
    >
    >
    I know in Perl I had to do some special gyrations to pass the right
    structue for ArrayOfString to this same web service. Is there any way
    to force a type in Python or any other ideas on how to do this?

    Comment

    Working...