SOAPpy : How do I prefix items with a string in a SOAP/XML request?

Discussion in 'Python' started by Doug Farrell, Aug 28, 2003.

  1. Doug Farrell

    Doug Farrell Guest

    Hi everyone,

    I'm trying to build a program to interface to a SOAP/XML interface
    provided by one of our vendors. This interface is built with MS SOAP
    Toolkit 3.0, so I'm guessig they are running a .NET server. I'm trying
    to build my program with Python as I've got to deploy on both Linux
    and Sun/Solaris platforms. I'm developing on RedHat Linux 8.0 using
    Python 2.2.1 and SOAPpy 0.10.2.

    My experimental program almost works, but it isn't putting a necessary
    prefix string on the XML items in the request. Here is the incorrect
    request my program is generating:

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/1999/XMLSchema">
    <SOAP-ENV:Body>
    <ns1:Init xmlns:ns1="http://some.web.service/" SOAP-ENC:root="1">
    <authRequest>
    <userPwd xsi:type="xsd:string">doug</userPwd>
    <userID xsi:type="xsd:string">beta.grolier.doug</userID>
    <profileID xsi:type="xsd:string"></profileID>
    </authRequest>
    </ns1:Init>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>


    Here is what a working request should look like:

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/1999/XMLSchema">
    <SOAP-ENV:Body>
    <ns1:Init xmlns:ns1="http://some.web.service/" SOAP-ENC:root="1">
    <ns1:authRequest>
    <ns1:userPwd xsi:type="xsd:string">doug</ns1:userPwd>
    <ns1:userID xsi:type="xsd:string">beta.grolier.doug</ns1:userID>
    <ns1:profileID xsi:type="xsd:string"></ns1:profileID>
    </ns1:authRequest>
    </ns1:Init>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    The difference is the 'ns1:' prefix in front of the userPwd, userID
    and profileID items in the XML part of the request. Here is my sample
    code that is generating the incorrect SOAP request:

    #!/usr/bin/python

    from SOAPpy import SOAPProxy
    from SOAPpy import SOAPConfig

    url = "http://some.web.service/direct/direct.asmx"
    ns = "http://some.web.service/"
    sa = "http://some.web.service/Init"

    server = SOAPProxy(url, namespace=ns, soapaction=sa,
    config=SOAPConfig(debug=1))

    rsp = server._ns('ns1',
    ns).Init(authRequest={'userID':'beta.grolier.doug', 'userPwd':'doug',
    'profileID':''})

    print "I'm outta here"

    The degug=1 flag makes the program dump the XML requests/responses,
    but then it crashes with a traceback because the message I'm getting
    back is the server error message, not the expected response.

    Does anyone have any ideas/suggestions on how I can tell the SOAPpy
    module to add the 'ns1:' prefix to the the items in the request?

    Thanks for your help,
    Doug Farrell
    Doug Farrell, Aug 28, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Tyler
    Replies:
    36
    Views:
    1,448
    Darryl L. Pierce
    Dec 10, 2004
  2. Harry George
    Replies:
    1
    Views:
    394
    Harry George
    Dec 1, 2004
  3. Jim
    Replies:
    1
    Views:
    751
    bruno modulix
    Apr 14, 2005
  4. Rodney

    SOAPpy SOAP and/or WSDL Question

    Rodney, Dec 4, 2005, in forum: Python
    Replies:
    0
    Views:
    362
    Rodney
    Dec 4, 2005
  5. Chris  Chiasson
    Replies:
    6
    Views:
    604
    Richard Tobin
    Nov 14, 2006
Loading...

Share This Page