/
Program.cs
43 lines (39 loc) · 1.02 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Discovery;
namespace SimpleService
{
[ServiceContract]
public class EchoService
{
[OperationContract]
public string Echo(string text)
{
return text;
}
}
class Program
{
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();
}
}
}
}