我有一个接口,对于同一个接口,我有多个实现。所以我想问你,我如何使用一台主机公开端点?
服务代码
[ServiceContract]
public interface ICalculator
{
[OperationContract]
int Add(int num1, int num2);
}
public class Calculator : ICalculator
{
public int Add(int num1, int num2)
{
return num1 + num2;
}
}
public class Calculator_Fake : ICalculator
{
public int Add(int num1, int num2)
{
return num1 + num1;
}
}
主机代码
class Program
{
static void Main(string[] args)
{
ServiceHost host = new ServiceHost(typeof(WCF_Service.CalService));
host.Open();
Console.ReadLine();
}
}
主机配置
<endpoint address="http://localhost:8000/CalService"
binding="basicHttpBinding"
contract="WCF_Service.ICalculator" />