[英]XMLRPC c# client to python client - method does not exists
我在網上搜索並看到以下問題: XML-RPC C#和Python RPC Server
我正在嘗試做一陣子,但失敗了。 我收到異常“不支持方法“ HelloWorld” ...”
[XmlRpcUrl("http://192.168.0.xxx:8000/RPC2")]
public interface HelloWorld : IXmlRpcProxy
{
[XmlRpcMethod]
String HelloWorld();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
HelloWorld proxy = CookComputing.XmlRpc.XmlRpcProxyGen.Create<HelloWorld>();
textBox1.Text = proxy.HelloWorld();
}
catch (Exception ex)
{
HandleException(ex);
}
}
我的Python服務器是:
class LGERequestHandler(SimpleXMLRPCRequestHandler):
rpc_paths = ('/RPC2',)
def HelloWorld():
return "This is server..."
server = SimpleXMLRPCServer(("192.168.0.xxx", 8000),
requestHandler=LGERequestHandler)
server.register_introspection_functions()
server.register_function("HelloWorld", HelloWorld)
server.register_instance(self)
# Run the server's main loop
server.serve_forever()
服務器已啟動並正在運行,但是仍然出現異常。
我發現了問題:
語法問題server.register_function("HelloWorld", HelloWorld)
應該是server.register_function(HelloWorld, "HelloWorld")
。
此更改也沒有起作用,因此我將函數名稱形式從helloWorld
更改為hello
並成功了(!)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.