XMLRPC c# client to python client - method does not exists

这一生的挚爱 提交于 2019-12-24 08:56:25

问题


I've searched the web and seen the following question: XML-RPC C# and Python RPC Server

I'm trying for a while to do the same, but I fail. I get the exception "Method "HelloWorld" is not supported..."

[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);
    }
}

And my Python server is:

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

The server is up and running, but I still get an exception.


回答1:


I found the problem:

  1. Syntax problem server.register_function("HelloWorld", HelloWorld) should be server.register_function(HelloWorld, "HelloWorld").

  2. This change also didn't work, so I changed the function name form helloWorld to hello and it worked(!)



来源:https://stackoverflow.com/questions/7124937/xmlrpc-c-sharp-client-to-python-client-method-does-not-exists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!