SOAPpy header authentication

Heran Li
2009-01-20
2013-05-02
  • Heran Li
    Heran Li
    2009-01-20

    Hi i am using SOAPpy WSDL proxy to call methods. The webservice needs authentication information included in the header field. I have written the code and output the outgoing and incoming msgs. But there is no header field included in the msg no matter how I setup the header. Please help with this bug. Thanks very much.

    ===============Python Code=================================
    from SOAPpy import *

    wsdlFile = 'http://itsm.us.com/arsys/WSDL/public/itsm.us.com/IncidentManagementServiceQuery?wsdl'
    username = '****'
    password = 'xxxx'
    n = 'urn:IncidentManagementServiceQuery'

    ct = structType(data={'userName':username,'password':password})
    ct._validURIs = []
    ct._ns = ("ns1", "urn:MLIncidentManagementServiceQuery")
    hd = headerType(data = {'AuthenticationInfo' : ct})

    #Or using:
    #hd = headerType(data={'AuthenticationInfo':{'userName':username,'password':password}})
    server = WSDL.Proxy(wsdlFile)
    server.soapproxy.hearder = hd

    server.soapproxy.config.dumpSOAPOut=1
    server.soapproxy.config.dumpSOAPIn=1

    server.QryByCaseID('INC000009640041')

    ============= Output=====================
    *** Outgoing SOAP ******************************************************
    <?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>
    <QryByCaseID SOAP-ENC:root="1">
    <v1 xsi:type="xsd:string">INC000009640041</v1>
    </QryByCaseID>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    ************************************************************************
    *** Incoming SOAP ******************************************************
    <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xml
    ns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapen
    v:Fault><faultcode>soapenv:Server.userException</faultcode><faultstring>ERROR (302): Entry does not exist in database
    ; </faultstring><detail><ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">apps976-s</ns1:hostname></detail></soap
    env:Fault></soapenv:Body></soapenv:Envelope>

    SOAPpy.Types.faultType: <Fault soapenv:Server.userException: ERROR (302): Entry does not exist in database; : <SOAPpy
    .Types.structType detail at 4135190988>: {'hostname': 'apps976-s'}>