Struggling with simple SOAP call...

278 views
Skip to first unread message

Pbop

unread,
Apr 19, 2016, 8:28:17 AM4/19/16
to web2py-users
I am trying to learn how to use the pysimplesoap client to consume a service outside of Web2Py. 

Example in book works great, and I have not some useful threads in the community about authentication which is phase 2, but I am just trying to start simple. Unfortunately, my proof of concept to use the soap client to readily available services on the WWW is bombing. I am sure it is something simple... Any help is appreciated.  

def test_4():
  from gluon.contrib.pysimplesoap.client import SoapClient, SoapFault
  client = SoapClient (wsdl="http://www.webservicex.net/geoipservice.asmx?wsdl", location="http://www.webservicex.net/", cacert=None, trace=False)
  # call SOAP method
  response = client.GetGeoIP(IPAddress='24.194.5.187')
  try:
    result = response['GetGeoIPResult']
  except SoapFault:
    result = None
  return dict(xml_request=client.xml_request,
            xml_response=client.xml_response,
            result=result)

Here is my Traceback

raceback (most recent call last):
File "C:\web2py_src\web2py\gluon\restricted.py", line 227, in restricted
exec ccode in environment
File "C:/web2py_src/web2py/applications/webservices/controllers/sample.py", line 102, in <module>
File "C:\web2py_src\web2py\gluon\globals.py", line 417, in <lambda>
self._caller = lambda f: f()
File "C:/web2py_src/web2py/applications/webservices/controllers/sample.py", line 94, in test_5
response = client_soap.GetGeoIP(IPAddress='24.194.5.187')
File "C:\web2py_src\web2py\gluon\contrib\pysimplesoap\client.py", line 165, in <lambda>
return lambda self=self, *args, **kwargs: self.call(attr, *args, **kwargs)
File "C:\web2py_src\web2py\gluon\contrib\pysimplesoap\client.py", line 242, in call
jetty=self.__soap_server in ('jetty',))
File "C:\web2py_src\web2py\gluon\contrib\pysimplesoap\simplexml.py", line 56, in __init__
self.__document = xml.dom.minidom.parseString(text)
File "C:\Python27\lib\xml\dom\minidom.py", line 1928, in parseString
return expatbuilder.parseString(string)
File "C:\Python27\lib\xml\dom\expatbuilder.py", line 940, in parseString
return builder.parseString(string)
File "C:\Python27\lib\xml\dom\expatbuilder.py", line 223, in parseString
parser.Parse(string, True)
ExpatError: mismatched tag: line 24, column 2

Dave S

unread,
Apr 19, 2016, 3:26:24 PM4/19/16
to web2py-users


On Tuesday, April 19, 2016 at 5:28:17 AM UTC-7, Pbop wrote:
I am trying to learn how to use the pysimplesoap client to consume a service outside of Web2Py. 

Example in book works great, and I have not some useful threads in the community about authentication which is phase 2, but I am just trying to start simple. Unfortunately, my proof of concept to use the soap client to readily available services on the WWW is bombing. I am sure it is something simple... Any help is appreciated.  

[...] 
  File "C:/web2py_src/web2py/applications/webservices/controllers/sample.py", line 94, in test_5
response = client_soap.GetGeoIP(IPAddress='24.194.5.187')
File "C:\web2py_src\web2py\gluon\contrib\pysimplesoap\client.py", line 165, in <lambda>
return lambda self=self, *args, **kwargs: self.call(attr, *args, **kwargs)
File "C:\web2py_src\web2py\gluon\contrib\pysimplesoap\client.py", line 242, in call
jetty
=self.__soap_server in ('jetty',))
File "C:\web2py_src\web2py\gluon\contrib\pysimplesoap\simplexml.py", line 56, in __init__
self.__document = xml.dom.minidom.parseString(text)
File "C:\Python27\lib\xml\dom\minidom.py", line 1928, in parseString
return expatbuilder.parseString(string)
File "C:\Python27\lib\xml\dom\expatbuilder.py", line 940, in parseString
return builder.parseString(string)
File "C:\Python27\lib\xml\dom\expatbuilder.py", line 223, in parseString
parser
.Parse(string, True)
ExpatError: mismatched tag: line 24, column 2


This sounds, at first glance, like a badly formed response from the remote target.  Any chance you can get a wireshark or tcpdump trace of the response? (Ah, Windows ... not tcpdump, then; netsh is the native trace)   

Plan B would be to hack the lower-level code to try to find out what exactly it is complaining about.  Wordpad doesn't show line numbers for me, but it looks like the error message is coming from whatever parser has been instantiated, and that goes back to  [somewhere]\pyexpat.py, at which point I've lost the trail.

An easy thing to do would be to try another service, and see if you still get the same error.

/dps

Phil Baruch

unread,
Apr 20, 2016, 12:20:04 AM4/20/16
to web...@googlegroups.com
Thanks Dave for the reply. 

 I downloaded wireshark, and I am not seeing the packet, and sorting by destination address does not show the packet. now it may be there and I am not looking at Wireshark the right way. I went and tried a half dozen other open source / free SOAP web services from weather, to zipcodes, to stock tickers, to math etc and nothing worked. I sure do not have the skillset to go deep into the code to troubleshoot and I am inclined to think either I am dong something wrong or in-fact the SOAP client is broken. I am a little frustrated as this should not be that difficult. Perhaps you or someone might share a sample SOAP client actually working from an Open Source SOAP provider.  I think I have a good handle on how to do it, but either I am being clumsy or there is something broken. Here are two...


http://www.webservicex.net/New/Home/ServiceDetail/19

http://www.service-repository.com/operation/operations?id=58


Phil 


--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/BcDhdwWralA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages