Exemple #1
0
 static void Main(string[] args)
 {
     using (HellworldServiceClient client = new HellworldServiceClient())
     {
         Console.WriteLine("服务返回的结果是: {0}", client.GetHelloWord());
         Console.WriteLine("服务返回的结果是: {0}", client.GetHelloWord());
     }
     Console.Read();
 }
Exemple #2
0
        static void Main(string[] args)
        {
            //利用服务引用  需要配置文件
            using (HellworldServiceClient proxy = new HellworldServiceClient())
            {
                Console.WriteLine("服务返回的结果是: {0}", proxy.GetHelloWorldWithoutParam());
            };

            //由通道工厂生成的通道类型  不需要配置文件
            var factory = new ChannelFactory<IHelloWorld>(new WSHttpBinding(), new EndpointAddress("http://127.0.0.1:8888/HelloWorldService"));
            var client = factory.CreateChannel();

            Console.WriteLine("服务返回的结果是: {0}", client.GetHelloWord("Test"));

            Console.Read();
        }