forked from CoreWCF/CoreWCF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
30 lines (27 loc) · 1.08 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
using System;
using System.ServiceModel;
namespace NetCoreClient
{
class Program
{
static void Main(string[] args)
{
var factory = new ChannelFactory<Contract.IEchoService>(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8808/nettcp"));
factory.Open();
var channel = factory.CreateChannel();
((IClientChannel)channel).Open();
Console.WriteLine("net.tcp Echo(\"Hello\") => " + channel.Echo("Hello"));
((IClientChannel)channel).Close();
factory.Close();
factory = new ChannelFactory<Contract.IEchoService>(new BasicHttpBinding(), new EndpointAddress("http://localhost:8080/basichttp"));
factory.Open();
channel = factory.CreateChannel();
((IClientChannel)channel).Open();
Console.WriteLine("http Echo(\"Hello\") => " + channel.Echo("Hello"));
((IClientChannel)channel).Close();
factory.Close();
Console.WriteLine("Hit enter to exit");
Console.ReadLine();
}
}
}