Client.cs
资源名称:Visual.rar [点击查看]
上传用户:yiyuerguo
上传日期:2014-09-27
资源大小:3781k
文件大小:1k
源码类别:
C#编程
开发平台:
Others
- using System;
- using System.Runtime.Remoting;
- using System.Runtime.Remoting.Channels;
- using System.Runtime.Remoting.Channels.Http;
- using MathLibrary;
- namespace MathClient
- {
- class ClientMain
- {
- static void Main(string[] args)
- {
- // Create and register the channel. The default channel ctor
- // does not open a port, so we can't use this to receive messsages.
- HttpClientChannel channel = new HttpClientChannel();
- ChannelServices.RegisterChannel(channel);
- // Go get the remote object
- Object remoteObj = Activator.GetObject(
- typeof(MathLibrary.SimpleMath),
- "http://localhost:13101/myURI.soap"
- );
- // Cast the returned proxy to the SimpleMath type
- SimpleMath math = (SimpleMath)remoteObj;
- // Use the remote object
- Console.WriteLine("5 + 2 = {0}", math.Add(5,2));
- Console.WriteLine("5 - 2 = {0}", math.Subtract(5,2));
- // Ask user to press enter
- Console.Write("Press enter to end");
- Console.ReadLine();
- }
- }
- }