Working with soaplib...

Gabriel Ambuehl gabriel_ambuehl-py at buz.ch
Fri Mar 30 13:55:23 EST 2001


-----BEGIN PGP SIGNED MESSAGE-----

Hello,
I've been trying to work with either soaplib or XMLRPC (I don't care
too much about which one gets used as long as my RPC works. As SOAP
looks to be a much broader standard, it would probably the one to
prefer, but this is largely theoretical as this is an inhouse project
and I plan to write a small wrapper function which should take care of
the underlying transport anyway)and while writing clients is simple, I
run into serious problems when it comes to writing servers (soapserver
got modified to not use any try/except constructions so it will dump
everything to
the screen which is to be preferred as error handling seems to be
broken, i.e. the client will just get some list containing other,
empty lists):

- ----------
import SocketServer
import soapserver

class TestRequestHandler(soapserver.RequestHandler):
    #Override method:
    def call(self, method, params):
        print "Dispatching: ", method, params
        try:
            server_method = getattr(self, method)
        except:
            raise AttributeError, "Server does not contain SOAP
procedure %s" % method
        return server_method(method, params)

    def equal_five(self, method, params):
        print "inside equal_five()"
        return 5

    def test(self, method, params):
        return params

    def add(self, method, params):
        c=params[0]+params[1]
        print "c: " + c
        return c

if __name__ == '__main__':
    server = SocketServer.TCPServer(('', 8000), TestRequestHandler)
    server.serve_forever()

- -----------

And the client
>>> import soaplib
>>> server = soaplib.ServerProxy("http://local:8000")
>>> print server.test('test')

this works without any problems and yields
test
on the screen (as one would expect)
Now
>>> print server.equal_five()

won't work, the server dumps the following error:

Dispatching:  equal_five ()
inside equal_five()
- ----------------------------------------
Exception happened during processing of request from ('10.2.2.100',
3574)
Traceback (most recent call last):
  File "/usr/local/lib/python2.0/SocketServer.py", line 221, in
handle_request
    self.process_request(request, client_address)
  File "/usr/local/lib/python2.0/SocketServer.py", line 247, in
process_request
    self.finish_request(request, client_address)
  File "/usr/local/lib/python2.0/SocketServer.py", line 251, in
finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/lib/python2.0/SocketServer.py", line 385, in
__init__
    self.handle()
  File "/usr/local/lib/python2.0/BaseHTTPServer.py", line 266, in
handle
    method()
  File "\\local\admin_net\soaplib-0.8-20000621\soapserver.py", line
37, in do_POST
  File "\\local\admin_net\soaplib-0.8-20000621\soaplib.py", line 654,
in dumps
AssertionError: argument must be tuple, method call/response, or fault
instance
- ----------------------------------------

(the script lives on a FreeBSD machine and the client gets loaded over
samba from it, that's why the strange UNCs are there)

I think there's something wrong with my return statements of the
not working functions but can't seem to figure out what to do about
it. What data type do I need to return so soaplib.dumps
(xmlrpclib.dumps appears to be having exactly the same problem, for
that matter) can handle it? A tuple like
return (value,)
doesn't appear to be working, neither does
return ([value,])

Any help would be greatly appreciated.




Thanks in advance and best regards,
 Gabriel

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.0.2i

iQEVAwUBOsTIj8Za2WpymlDxAQGO+Af+Ms+cs0fY6Nu0njzyqUttJvs/Cb7o9QXi
6VL/7h3dxJ1eBxY+NNDgZeGlf1V0YgkjTjSYknksxARcW8wdILLK5WJPlbqBsZWb
TiUCWbNzCXVVLVF5DzEUmtlL5QMSR4cceRbufD/Kpfi/87xgcPTRzVoMC2vGMIKh
PXLn9f0L4MjvUWYcdXOWrZDRAQVfcT3ivaK4bQLeiRkI+lTWTcHSdjdKAKyHMvKh
owpUbzzwL7p4l1wYxjpgfZStNEulMzGIpw6FebdGRj8lwyCO1wiOyV+bBm40o6b1
RZ6ihz2Pvgl9Q+Q2Z40woOO/dTq9r1tFbQPT16WwL77xlXj+7PRcvg==
=NX/H
-----END PGP SIGNATURE-----






More information about the Python-list mailing list