First, I highly recommend http://www.soapclient.com/soaptest.html as a resource to reverse engineer soap parameters and test soap calls. If it works from this site and not in your Web2Py code, your code is broken, not the SOAP client. The soap client parameters are poorly documented and the documentation in the Webplus manual looks at the implementation through the lens from what works in Web2Py, which is probably a best practice / standard practice, but is not followed in the free SOAP services out there. The soaptest site will return a ServerAddress once the WSDL/Description file is specified. This is the location property when defining the soap client.
I know if I had a working sample, it would have saved me time, so for the benefit of the community, here is a working sample; however, I would like to get feedback in how I am parsing out the XML response as while it works this seems a little convoluted with tools I have used in the past. I got this approach from another thread: def test_soap_sub2(): from gluon.contrib.pysimplesoap.client import SoapClient, SoapFault from xml.dom import minidom # create a SOAP client client = SoapClient(location="http://ladonize.org/python-demos/Calculator/soap", cacert=None, trace=True, namespace='addResponse', ns='addResponse') # call SOAP method response = client.add(a='5',b='54') try: result = response['result'] x = client.xml_response parsed_data = minidom.parseString(x) newresult = parsed_data.getElementsByTagName('result') result = newresult[0].firstChild.toxml() except SoapFault: result = 'l' return dict(xml_request=client.xml_request, xml_response=client.xml_response, result=result) Note that I am importing minidom from xml.dom import minidom And then am jumping through this hoop to get the result... parsed_data = minidom.parseString(x) newresult = parsed_data.getElementsByTagName('result') result = newresult[0].firstChild.toxml() In the example in the manual, the result assignment is: result = response('AddResult') The SOAP call has this response: <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><AddIntegersResponse xmlns="http://localhost:8000/webservices/sample/call/soap"><AddResult>5</AddResult></AddIntegersResponse></soap:Body></soap:Envelope> So my first question is why does this work? The AddResult tags are not wrapped in a namespace, but I am missing something fundamental here. In my working example above. the soap calls has this response: <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:Calculator" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><ns:addResponse><result>59</result></ns:addResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> Where the result tag is wrapped around <ns:addResponse><result>59</result></ns:addResponse> So the second question is whether there is a better way to access the result tag without having to parse the dom? Or said a different way, why does the approach in the manual eg result = response('result') fail? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.