On my server, I'm using the standard example for Python (with an extra Hello World Method) and on the Client side I'm using the XML-RPC.NET Library in C#. But everytime I run my client I get the exception that the method is not found. Any Ideas how fix that.
thanks!
Python:
from SimpleXMLRPCServer import SimpleXMLRPCServer
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
# Restrict to a particular path.
class RequestHandler(SimpleXMLRPCRequestHandler):
rpc_paths = ('/RPC2',)
# Create server
server = SimpleXMLRPCServer(("", 8000),
requestHandler=RequestHandler)
server.register_introspection_functions()
# Register pow() function; this will use the value of
# pow.__name__ as the name, which is just 'pow'.
server.register_function(pow)
# Register a function under a different name
def adder_function(x,y):
return x + y
server.register_function(adder_function, 'add')
def HelloWorld():
return "Hello Henrik"
server.register_function(HelloWorld,'HelloWorld')
# Register an instance; all the methods of the instance are
# published as XML-RPC methods (in this case, just 'div').
class MyFuncs:
def div(self, x, y):
return x // y
server.register_instance(MyFuncs())
# Run the server's main loop
server.serve_forever()
C#
namespace XMLRPC_Test
{
[XmlRpcUrl("http://188.40.xxx.xxx:8000")]
public interface HelloWorld : IXmlRpcProxy
{
[XmlRpcMethod]
String HelloWorld();
}
[XmlRpcUrl("http://188.40.xxx.xxx:8000")]
public interface add : IXmlRpcProxy
{
[XmlRpcMethod]
int add(int x, int y);
}
[XmlRpcUrl("http://188.40.xxx.xxx:8000")]
public interface listMethods : IXmlRpcProxy
{
[XmlRpcMethod("system.listMethods")]
String listMethods();
}
class Program
{
static void Main(string[] args)
{
listMethods proxy = XmlRpcProxyGen.Create<listMethods>();
Console.WriteLine(proxy.listMethods());
Console.ReadLine();
}
}
}
XML-RPC is a specification that enables communication between WordPress and other systems. It did this by standardizing those communications, using HTTP as the transport mechanism and XML as the encoding mechanism.
XML-RPC requests are a combination of XML content and HTTP headers. The XML content uses the data typing structure to pass parameters and contains additional information identifying which procedure is being called, while the HTTP headers provide a wrapper for passing the request over the Web.
Remote Procedure Call (RPC) With RPC, a client can connect to a server running on another platform. For example: In theory, the server could be written for Linux and the client could be written for Win32.
XML-RPC is a quick-and-easy way to make procedure calls over the Internet. It converts the procedure call into an XML document, sends it to a remote server using HTTP, and gets back the response as XML. This library provides a modular implementation of XML-RPC for C and C++.
Does it work if you change the declaration to this?
[XmlRpcUrl("http://188.40.xxx.xxx:8000/RPC2")]
From the Python docs:
SimpleXMLRPCRequestHandler.rpc_paths
An attribute value that must be a tuple listing valid path portions of the URL for receiving XML-RPC requests. Requests posted to other paths will result in a 404 “no such page” HTTP error. If this tuple is empty, all paths will be considered valid. The default value is ('/', '/RPC2').
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With