我在网上搜索并看到以下问题:XML-RPC C# and 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()
服务器已启动并正在运行,但我仍然遇到异常。