客户端代码:
1.定义要被远程调用的方法接口
- public interface IRPCMethod
- {
- [XmlRpcMethod("SayHello")]
- string SayHello();
- }
复制代码
2.调用
- private static void Main(string[] args)
- {
- var chnl = new HttpChannel(null, new XmlRpcClientFormatterSinkProvider(), null);
- ChannelServices.RegisterChannel(chnl, false);
- svr = (IRPCMethod)Activator.GetObject(typeof(IRPCMethod), "http://localhost:8088/RPC2");
- Console.WriteLine("成功注册信道");
- string str = svr.SayHello();
- Console.WriteLine(str);
- }
|