(程式1) using System; namespace C64.Share { public interface IMyService { string HelloService(string name); } } ------------------------ (程式2) using System; using C64.Share; namespace Server { public class MyService:MarshalByRefObject,IMyService { public MyService():base() { Console.WriteLine("Service Object is Created!"); } public string HelloService(string name) { return "Hello "+name; } } } ------------------------ (程式3) Using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Http; using C64.Share; namespace Server { class Startup { [STAThread] static void Main(string[] args) { HttpChannel chnl=new HttpChannel(1234); ChannelServices.RegisterChannel(chnl); RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyService),"MyService.soap",WellKnownObjectMode.Singleton); System.Console.WriteLine("Remoting Server Running..."); Console.ReadLine(); } } } ------------------------ (程式4) using System; using System.Collections.Specialized; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Http; using C64.Share; namespace Client { class Startup { static IMyService SimpleBinding() { HttpChannel chnl=new HttpChannel(); ChannelServices.RegisterChannel(chnl); return (IMyService)Activator.GetObject(typeof(IMyService),"http://localhost:1234/MyService.soap"); } [STAThread] static void Main(string[] args) { //use simple binding IMyService obj=SimpleBinding(); Console.WriteLine(obj.HelloService("code6421")); Console.ReadLine(); } } } ------------------------ (程式5) static void Main(string[] args) { ……………… //use web reference MyServiceService obj=new MyServiceService(); Console.WriteLine(obj.HelloService("code6421")); Console.ReadLine(); } ------------------------