什么可能导致xmlrpclib.ResponseError:ResponseError()?

时间:2010-05-14 20:31:38

标签: python xml-rpc simplexmlrpcserver

我正在尝试使用XML-RPC。

我有以下服务器脚本(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'

以及以下客户端脚本:

import xmlrpclib

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

我已经在本地测试了它并且工作正常。所有它都会从客户端脚本中吐出输入,这是正确的。

但是,当我尝试在远程服务器上执行此操作时,我收到以下错误:

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()

任何可能导致此问题的想法?

更新

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 个答案:

答案 0 :(得分:3)

看起来在远程计算机上的那个端口上正在运行其他东西。并发回一个意想不到的答案。

我会检查服务器是否正确启动。然后检查防火墙设置中是否有可能影响事物的任何内容。

您还可以打开客户端中的详细标记,看看是否能解决问题。

编辑:

因此,详细输出可以解决问题:您没有运行服务器,而是通过普通的Web服务器共享它!

您需要在远程计算机上运行服务器。