pythonsoapsoappyaxis2c

namespaces in SOAPpy not working as expected


I'm having an issue correctly interfacing with a SOAP API running on Axis2:

What happens is I should call the login method with two arguments (loginName and password) and it returns an authentication token that I will use for subsequent interaction.

#!/usr/bin/python

from SOAPpy import SOAPProxy

s_user = 'Administrator'
s_pass = 'securityThroughObscurity'
s_host = '192.168.76.130:8998'

namespace = 'http://bcc.inc.com/IncSecurity'
url = 'http://' + s_host + '/axis2/services/IncSecurityService'

DHCPServ = SOAPProxy(url, namespace)
DHCPServ.config.dumpSOAPOut = 1
DHCPServ.config.dumpSOAPIn = 1
DHCPResp = DHCPServ.login(loginName=s_user, password=s_pass)

The Axis2 server on the other side returns an XML error stating Data element of the OM Node is NULL. Looking at the Axis2 logs, I see the error is adb_login.c(383) non nillable or minOuccrs != 0 element loginName missing

I then packet captured the login XML from a known working Java client versus the XML from this client and these are the differences between the two:

SOAPpy:

<ns1:login xmlns:ns1="http://bcc.inc.com/IncSecurity" SOAP-ENC:root="1">
<password xsi:type="xsd:string">securityThroughObscurity</password>
<loginName xsi:type="xsd:string">Administrator</loginName>
</ns1:login>

Java:

<ns2:login xmlns:ns2="http://bcc.inc.com/IncSecurity">
<ns2:loginName>Administrator</ns2:loginName>
<ns2:password>securityThroughObscurity</ns2:password>
</ns2:login>

So this means that for some reason (probably related to my lack of knowledge in Python and SOAPpy) the namespace is not being applied to the variables being used in the login method, so by all accounts they don't actually exist and the error is warranted.

Also, it seems to be flipping the variables around and putting the password before loginName but I don't think that matters much.

What am I doing wrong?


Solution

  • Looks like it's a known bug in SOAPPy, someone has suggested a simple patch: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=523083

    Alternately (assuming you have access to the service WSDL), SOAPPy lets you specify a WSDL instead of just a namespace. This looks like it will provide better namespace information to the envelope generation code. http://diveintopython.net/soap_web_services/introspection.html

    Finally, if SOAPPy just isn't working for you, try Suds (it's better documented than SOAPPy).

    from suds.client import Client
    from suds.wsse import *
    client = Client(WSDL_LOCATION)
    guid = client.service.someFunctionName("a string argument", 42)
    

    Good luck!