-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathProgram.cs
More file actions
38 lines (29 loc) · 1.46 KB
/
Program.cs
File metadata and controls
38 lines (29 loc) · 1.46 KB
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//The service contract is defined using Connected Service "WCF Web Service", generated from the service by the dotnet svcutil tool.
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
HttpTransportBindingElement httpTransportBindingElement = basicHttpBinding.CreateBindingElements().Find<HttpTransportBindingElement>();
MessageEncodingBindingElement encodingBindingElement = new GZipMessageEncodingBindingElement();
CustomBinding binding = new CustomBinding(new BindingElement[]
{
encodingBindingElement,
httpTransportBindingElement
});
var endpointAddress = new EndpointAddress("http://localhost:5000/gzipMessageEncoding");
// Create a client with given client endpoint configuration
EchoServiceClient client = new EchoServiceClient(binding, endpointAddress);
Console.WriteLine("Calling Echo(string):");
Console.WriteLine("Server responds: {0}", client.Echo("Simple hello"));
Console.WriteLine();
Console.WriteLine("Calling BigEcho(string[]):");
string[] messages = new string[64];
for (int i = 0; i < 64; i++)
{
messages[i] = "Hello " + i;
}
Console.WriteLine("Server responds: {0}", client.BigEcho(messages));
//Closing the client gracefully closes the connection and cleans up resources
client.Close();
Console.WriteLine();
Console.WriteLine("Press <ENTER> to terminate client.");
Console.ReadLine();