I am using lib xml-rpc.net.2.5.0 for creating a XML RPC client in C# which invokes some python methods. The client is located in a Windows7 machine and the server is located in VMWare running red hat.
Client code which invokes python function (code inside main method):
IRemoteKillTest iRemoteKillTest = XmlRpcProxyGen.Create<IRemoteKillTest>();
int result = iRemoteKillTest.kill();
Console.WriteLine("Result = " + result);
Console.ReadLine();
Client Interface:
[XmlRpcUrl("http://192.ZZZ.YYY.XXX:8000/RPC2")]
public interface IRemoteKillTest : IXmlRpcProxy
{
[XmlRpcMethod]
int kill();
}
[XmlRpcUrl("http://192.ZZZ.YYY.XXX:8000/RPC2")]
public interface IRemoteMsgTest : IXmlRpcProxy
{
[XmlRpcMethod]
string msg();
}
Server code:
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
import subprocess
class RequestHandler(SimpleXMLRPCRequestHandler):
rpc_paths = ('/RPC2',)
server = SimpleXMLRPCServer(("192.ZZZ.YYY.XXX", 8000), requestHandler=RequestHandler)
server.register_introspection_functions()
class MyFuncs:
def msg(self):
return "It Works!"
def kill(self):
status = subprocess.call("ps -ef | grep <my_grep_info> | grep -v grep | awk '{ print $2 }' | xargs kill", shell=True)
return status
server.register_instance(MyFuncs())
server.serve_forever()
If the client calls function msg from python it is executed successfully and the string is returned to c# but if it calls function kill i got the following exception:
XmlRpcFaultException:
Server returned a fault exception: [1] exceptions.Exception:method "kill" is not supported
It happens for any other python method like os.listdir, subprocess.Popen and so on. I have made a test calling kill method from a python client running inside VMWare red hat and it works.
I need a help as soon as possible, so pls if anyone has already faced it and have a explanation for that it will be very usefull. Thanks in advance and regards,