using System;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
class Program
{
static void Main(
string[] args)
{
ServiceHost serviceHost =
new ServiceHost(
typeof(Service1),
new Uri(
"http://localhost:8000/EssentialWCF")); //ServiceHost serviceHost = new ServiceHost(typeof(Service1));
ServiceMetadataBehavior behavior = serviceHost.Description.Behaviors.Find<ServiceMetadataBehavior>
();
if (behavior==
null)
{
behavior =
new ServiceMetadataBehavior();
behavior.HttpGetEnabled =
true; //behavior.HttpGetUrl=new Uri("http://localhost:8000/EssentialWCF");
serviceHost.Description.Behaviors.Add(behavior); //serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "http://localhost:8002/Essential");
}
serviceHost.Open();
Console.ReadLine();
}
[ServiceContract]
public interface IService1
{
[OperationContract]
void DoWork();
}
[ServiceContract]
public interface IService2
{
[OperationContract]
void Do();
}
public class Service1 : IService1, IService2
{
public static void Configure(ServiceConfiguration config)
{
Uri httpAddress =
new Uri(
"http://localhost:8002");
Binding binding =
new WSHttpBinding();
config.AddServiceEndpoint(typeof(IService1), binding,
"http://localhost:8003/a");
config.AddServiceEndpoint(typeof(IService2), binding,
"http://localhost:8003/b");
}
public void Do()
{
}
public void DoWork()
{
}
}
}
转载于:https://www.cnblogs.com/kotomi/p/8242338.html