本文整理汇总了C#中System.ServiceModel.ServiceHost.AddDefaultEndpoints方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceHost.AddDefaultEndpoints方法的具体用法?C# ServiceHost.AddDefaultEndpoints怎么用?C# ServiceHost.AddDefaultEndpoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.ServiceHost
的用法示例。
在下文中一共展示了ServiceHost.AddDefaultEndpoints方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Uri baseAddress = new Uri("http://localhost:8080/Service");
// Create the ServiceHost.
using (ServiceHost host = new ServiceHost(typeof(CounterService), baseAddress))
{
// Enable metadata publishing.
//ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
//smb.HttpGetEnabled = true;
//smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
//host.Description.Behaviors.Add(smb);
host.AddDefaultEndpoints();
//var wsContract = new ContractDescription("WSHttpDefault");
//var wsEndpoint = new ServiceEndpoint(
// Open the ServiceHost to start listening for messages. Since
// no endpoints are explicitly configured, the runtime will create
// one endpoint per base address for each service contract implemented
// by the service.
host.Open();
Console.WriteLine("The service is ready at {0}", baseAddress);
Console.WriteLine("Press <Enter> to stop the service.");
Console.ReadLine();
// Close the ServiceHost.
host.Close();
}
}
示例2: Main
static void Main(string[] args)
{
//ServiceHost myHost = new ServiceHost(typeof(WCFService));
ServiceHost myHost = new ServiceHost(typeof(WCFService),
new Uri("http://localhost:9003/AI3"),
new Uri("net.tcp://localhost:9004/AI4"));
myHost.AddDefaultEndpoints();
myHost.AddServiceEndpoint(typeof(IWCFService), new BasicHttpBinding(), "http://localhost:9001/AI");
myHost.AddServiceEndpoint(typeof(IWCFService), new NetTcpBinding(), "net.tcp://localhost:9002/");
ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
behavior.HttpGetUrl = new Uri("http://localhost:8090/WCFService");
behavior.HttpGetEnabled = true;
myHost.Description.Behaviors.Add(behavior);
try
{
myHost.Open();
Console.WriteLine("Service is worked ! Status : " + myHost.State);
foreach (ServiceEndpoint ep in myHost.Description.Endpoints)
{
Console.WriteLine("A : {0} - B : {1} - C : {2}", ep.Address, ep.Binding.Name, ep.Contract.Name);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
示例3: GameServerForm_Load
private void GameServerForm_Load(object sender, EventArgs e)
{
statusList.Items.Clear();
statusList.Items.Add("Initializing");
host = new ServiceHost(typeof(GameService), baseAddress);
host.AddDefaultEndpoints();
statusList.Items.Add("Host started");
}
示例4: OnStart
protected override void OnStart(string[] args)
{
if (myHost != null)
{
myHost.Close();
}
// Create the host and specify a URL for an HTTP binding.
myHost = new ServiceHost(typeof(MathService),
new Uri("http://localhost:8080/MathServiceLibrary"));
myHost.AddDefaultEndpoints();
// Open the host.
myHost.Open();
}
示例5: OnStart
protected override void OnStart(string[] args) {
if (myHost != null) {
myHost.Close();
myHost = null;
}
Uri address = new Uri("http://localhost:8080/MathServiceLibrary");
myHost = new ServiceHost(typeof(MathService), address);
//BasicHttpBinding binding = new BasicHttpBinding();
//Type contract = typeof(IBasicMath);
//myHost.AddServiceEndpoint(contract, binding, address);
myHost.AddDefaultEndpoints();
myHost.Open();
}
示例6: Main
static void Main(string[] args)
{
using (var host = new ServiceHost(
typeof(EchoService),
new Uri("http://localhost:8081/Echo")))
{
host.AddServiceEndpoint(new UdpDiscoveryEndpoint());
host.AddDefaultEndpoints();
host.Open();
foreach (var endpoint in host.Description.Endpoints)
{
Console.WriteLine("{0} ({1})",
endpoint.Address,
endpoint.Binding.Name);
}
Console.ReadLine();
}
}
示例7: Start
public void Start()
{
Console.WriteLine("Starting local child process Service...");
Uri baseAddress = DiscoveryUtils.DiscoveryHelper.AvailableTcpBaseAddress;
this.FindCoordinator();
_processHost = new ServiceHost(typeof(ChildProcess), baseAddress);
_processHost.AddDefaultEndpoints();
_processHost.Open();
IntroduceToCoordinator();
_worker = new Thread(new ThreadStart(DoWork));
_worker.Start();
StartStatusServer();
}
示例8: StartElectionService
private void StartElectionService()
{
Console.WriteLine("Starting local election service...");
Uri baseAddress = DiscoveryHelper.AvailableTcpBaseAddress;
_election = new Election();
_election.Elected += ElectionElected;
_election.ProcessLost += ElectionProcessLost;
_election.FindConstituents();
_electionHost = new ServiceHost(typeof(Election), baseAddress);
_electionHost.AddDefaultEndpoints();
_electionHost.Open();
_election.ElectionIdentity = _electionHost.Description.Endpoints[1].Address;
Console.WriteLine("Election Service Started at: {0}", _electionHost.Description.Endpoints[1].Address.ToString());
Console.WriteLine();
IntroduceElection();
}
示例9: StartCoordinator
private void StartCoordinator()
{
Console.WriteLine("Starting local Coordinator Service...");
Uri baseAddress = DiscoveryUtils.DiscoveryHelper.AvailableTcpBaseAddress;
this.FindProcesses();
_coordinatorHost = new ServiceHost(typeof(Coordinator), baseAddress);
_coordinatorHost.AddDefaultEndpoints();
_coordinatorHost.Open();
IntroduceToProcesses();
}
示例10: Main
static void Main()
{
var realService = new ServiceHost(typeof (Service), new Uri("http://localhost:12345/a"));
realService.AddDefaultEndpoints();
var smb = new ServiceMetadataBehavior {HttpGetEnabled = true};
realService.Description.Behaviors.Add(smb);
realService.Open();
var serviceHost = new ServiceHost(typeof (Duck), new Uri("http://localhost:12345/router"));
serviceHost.AddDefaultEndpoints();
serviceHost.Open();
Console.WriteLine("Service is up and running.");
var routerClient = ChannelFactory<IServiceClient>.CreateChannel(new BasicHttpBinding(),
new EndpointAddress(
"http://localhost:12345/router"));
Console.WriteLine(routerClient.Op("bar"));
Console.ReadLine();
serviceHost.Close();
realService.Close();
}