2010-05-14 221 views
3

我正在試驗XML-RPC。什麼可能導致xmlrpclib.ResponseError:ResponseError()?

我有以下服務器腳本(蟒蛇):

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

任何想法可能導致此?

UPDATE:

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

回答

2

它看起來像別的東西該端口上運行在遠程計算機上。併發回一個意想不到的答案。

我會檢查服務器是否正確啓動。然後檢查防火牆設置中是否有任何可能影響事物的內容。

您也可以打開客戶端中的詳細標誌以查看是否可以解決問題。

編輯:

所以詳細的輸出清楚的問題:你是不是運行服務器,您共享它在一個正常的網絡服務器!

您需要在遠程計算機上運行服務器。

+0

謝謝道格拉斯;我正在研究你的建議。如果有幫助,我已經用verbose = True時得到的內容更新了帖子 – Tom 2010-05-14 20:55:47

相關問題