python服务端:使用SimpleXMLRPCServer
代码如下:
from SimpleXMLRPCServer import SimpleXMLRPCServer
def getTest():
return 'test message'
if __name__ == '__main__' :
server = SimpleXMLRPCServer(('localhost', 8888))
server.register_function(getTest, "getTest")
server.serve_forever()
C#客户端:使用CookComputing.XmlRpcV2.dll
代码如下:
[XmlRpcUrl("http://localhost:8888")]
public interface IStateName : IXmlRpcProxy
{
[XmlRpcMethod("getTest")]
string getTest();
}
class Test
{
static void Main()
{
IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
string message = proxy.getTest();
Console.WriteLine(message);
Console.ReadLine();
}
}
即可实现简单框架的搭建。