我正在开发一个正在创建服务器和客户机的应用程序;ServerAPI使用SimpleXMLRPCServer,ClientAPI使用xmlrpclib。客户端使用以下命令启动:
class w_Client:
def __init__(self, ServerIP, ServerPort, ClientIP):
self.conn = xmlrpclib.ServerProxy("http://" + ServerIP + ":" + str(ServerPort))
self.ClientIP = ClientIP在应用程序中按下按钮时,将创建一个xml规范文件并通过
def Create(self, XMLstring):
return self.conn.Create(XMLstring, self.ClientIP)我已经检查过以确保XMLstring是有效的XML;但是,当我按下按钮时,我得到以下错误:
Traceback (most recent call last):
File "/home/app/UI/MainWindow.py", line 461, in compile
xmlFile = compiler.compile()
File "/home/app/Core/Compiler.py", line 75, in compile
self.compile_top()
File "/home/app/Core/Compiler.py", line 354, in compile_top
status = mainWidgets["w_client"].Create(xmlString)
File "/home/app/Wireless/ClientAPI.py", line 12, in Create
return self.conn.Create(XMLstring, self.ClientIP)
File "/usr/lib/python2.7/xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1591, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1306, in single_request
return self.parse_response(response)
File "/usr/lib/python2.7/xmlrpclib.py", line 1482, in parse_response
return u.close()
File "/usr/lib/python2.7/xmlrpclib.py", line 794, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: "<type 'exceptions.TypeError'>:'NoneType' object has no attribute '__getitem__'">我还确保了ClientIP被正确传递。否则,我不能完全确定发生了什么,甚至不知道如何去修复它。
发布于 2015-09-23 04:17:27
<type 'exceptions.TypeError'>:'NoneType' object has no attribute '__getitem__'此异常可能是由您调用的xmlrpc方法(即服务器端)生成的。
我建议您将verbose=True添加到服务器代理的实例化中:
xmlrpclib.ServerProxy("http://" + ServerIP + ":" + str(ServerPort),verbose=True)这将允许您查看正在发送和接收的内容。
您调用的方法似乎需要一个dict
https://stackoverflow.com/questions/32724192
复制相似问题