pythonsudssoaplib

Python soaplib "Hello World" program - Parameters and types not showing up on client


I'm attempting to run the soaplib Hello World program:

import soaplib
from soaplib.core.service import rpc, DefinitionBase
from soaplib.core.model.primitive import String, Integer
from soaplib.core.server import wsgi
from soaplib.core.model.clazz import Array
from soaplib.core.service import soap


class HelloWorldService(DefinitionBase):
    @soap(String,Integer,_returns=Array(String))
    def say_hello(self,name,times):
        results = []
        for i in range(0,times):
            results.append('Hello, %s'%name)
        import pdb; pdb.set_trace() 
        return results

if __name__=='__main__':
    try:
        from wsgiref.simple_server import make_server
        soap_application = soaplib.core.Application([HelloWorldService], 'tns')
        wsgi_application = wsgi.Application(soap_application)
        server = make_server('localhost', 7789, wsgi_application)
        server.serve_forever()
    except ImportError:
        print "Error: example server code requires Python >= 2.5"

I was having problems connecting to the service, both using a browser and a simple suds client. I used the code from the top answer here to get a list of the methods of my little webservice, as well as they're parameters and types. The result I got wasn't particularly encouraging:

say_hello(None: say_hello)

So it appears that the reason that I was unable to call the function properly is that it's parameters and types do not appear to register: However, as far as I can tell this should not be the case. I'm particularly dumbfounded as this is the hello world program presented on the soaplib website.

I've searched both here and elsewhere, but I don't seem to find a similar problem anywhere. Any thoughts?


Solution

  • I've tried the soaplib "Hello world" example. It works if you add from soaplib.core.service import soap as you did.

    I've installed both soaplib and suds using pip install.

    $ pip freeze | grep -e'soaplib\|suds'
    soaplib==2.0.0-beta2
    suds==0.4
    

    It seems soaplib was refactored to rpclib which was replaced by spyne. It doesn't provide confidence in the project.