消费WCF服务托管在Windows服务

如何通过消耗托管在Windows服务的WCF服务步骤过程, 详细的编码和指令表示如下。

一旦成功,我们可以创建代理类业务,并开始使用客户端应用程序。这里,显示使用IIS托管型消费。

Consuming WCF hosted in Windows Service

 

添加 ServiceModel 参考。

Consuming WCF hosted in Windows Service

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespaceWindowServiceClient
{
  classProgram
  {
     staticvoid Main(string[] args)
     {
        //Creating Proxy for the MyService
        MyServiceClient client = newMyServiceClient();
        Console.WriteLine("Client calling the service...");
        Console.WriteLine("Sum of two numbers 5,6");
        Console.WriteLine(client.Add(5, 6));
        
        Console.WriteLine("Subtraction of two numbers 6,5");
        Console.WriteLine(client.Add(6, 5));
        
        Console.WriteLine("Multiplication of two numbers 6,5");
        Console.WriteLine(client.Add(6, 5));
        
        Console.WriteLine("Division of two numbers 6,3");
        Console.WriteLine(client.Add(6, 3));

        Console.Read();
     }
  }
}

 

Consuming WCF hosted in Windows Service

上一篇: 消费WCF服务托管在Windows激活服务 下一篇: WCF服务绑定