tags:

views:

107

answers:

1

Hi,

I am experimenting with XML-RPC.

I have the following server script (python):

from SimpleXMLRPCServer import SimpleXMLRPCServer

server = SimpleXMLRPCServer(('localhost', 9000))

def return_input(someinput):
return someinput

server.register_function(return_input)

try:
     print 'ctrl-c to stop server'
     server.serve_forever()
except KeyboardInterrupt:
     print 'stopping'

and the following client script:

import xmlrpclib

server = xmlrpclib.ServerProxy('http://www.example.com/pathto/xmlrpcTester2.py')
print server.return_input('some input')

I have tested this locally and it works fine. All it does it spit out the input from the client script, which is right.

However, when I try to do it on a remote server I get the following error:

Traceback (most recent call last):
  File "client.py", line 4, in <module>
    print server.return_input('some input')
  File     "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line     1199, in __call__
    return self.__send(self.__name, args)
  File     "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line     1489, in __request
    verbose=self.__verbose
  File     "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line     1253, in request
return self._parse_response(h.getfile(), sock)
 File     "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line     1392, in _parse_response
return u.close()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 836, in close
raise ResponseError()
xmlrpclib.ResponseError: ResponseError()

Any ideas what could cause this?

Thanks in advance for your help.

Tom

UPDATE:

when verbose=True:

send: 'POST /pythonScripts/xmlrpcTester2.py HTTP/1.0\r\nHost:         www.example.com\r\nUser-Agent: xmlrpclib.py/1.0.1 (by www.pythonware.com)\r\nContent-    Type: text/xml\r\nContent-Length: 166\r\n\r\n'
send: "<?xml version='1.0'?    >\n<methodCall>\n<methodName>return_input</methodName>\n<params>\n<param>\n<value><string>so  me input</string></value>\n</param>\n</params>\n</methodCall>\n"
reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Fri, 14 May 2010 20:52:25 GMT
header: Server: Apache/2.2.9 (Fedora)
header: Last-Modified: Fri, 14 May 2010 20:52:03 GMT
header: ETag: "7e206-13d-486940c17a2c0"
header: Accept-Ranges: bytes
header: Content-Length: 317
header: Connection: close
header: Content-Type: text/plain; charset=UTF-8
body: "from SimpleXMLRPCServer import SimpleXMLRPCServer\r\n\r\nserver =    SimpleXMLRPCServer(('localhost', 8000))\r\n\r\ndef return_input(someinput):\r\n\treturn     someinput\r\n\r\nserver.register_function(return_input)\r\n\r\ntry:\r\n     print 'ctrl-c to     stop server'\r\n     server.serve_forever()\r\nexcept KeyboardInterrupt:\r\n     print     'stopping'"
Traceback (most recent call last):
  File "client.py", line 4, in <module>
    print server.return_input('some input')
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1253, in request
    return self._parse_response(h.getfile(), sock)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 1392, in _parse_response
    return u.close()
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xmlrpclib.py", line 836, in close
    raise ResponseError()
xmlrpclib.ResponseError: ResponseError()
+1  A: 

It looks like something else is running on that port on the remote machine. And sending back an unexpected answer.

I would check the server is starting correctly. Then check if there is anything in the firewall setup that might be affecting things.

You could also turn on the verbose flag in the client to see if that sheds any light on the problem.

EDIT:

So the verbose output makes clear the problem: you aren't running the server, you are sharing it out over a normal webserver!

You need to run the server on the remote machine.

Douglas Leeder
Thanks Douglas; I am looking into your suggestions. If it helps I have updated the post with what I get when verbose=True
Tom