Assume I have a simple XML-RPC service that is implemented with Python:
from SimpleXMLRPCServer import SimpleXMLRPCServer # Python 2
def getTest():
return 'test message'
if __name__ == '__main__' :
server = SimpleXMLRPCServer(('localhost', 8888))
server.register_function(getTest)
server.serve_forever()
Can anyone tell me how to call the getTest()
function from C#?
Any code that you write using any compiled language like C, C++, or Java can be integrated or imported into another Python script. This code is considered as an "extension."
Calling Python from C# is easily possible via Pyrolite where your Python code is running as a Pyro4 server. It should be fast enough to handle "large arrays of numbers" however you didn't specify any performance constraints.
Not to toot my own horn, but: http://liboxide.svn.sourceforge.net/viewvc/liboxide/trunk/Oxide.Net/Rpc/
class XmlRpcTest : XmlRpcClient
{
private static Uri remoteHost = new Uri("http://localhost:8888/");
[RpcCall]
public string GetTest()
{
return (string)DoRequest(remoteHost,
CreateRequest("getTest", null));
}
}
static class Program
{
static void Main(string[] args)
{
XmlRpcTest test = new XmlRpcTest();
Console.WriteLine(test.GetTest());
}
}
That should do the trick... Note, the above library is LGPL, which may or may not be good enough for you.
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