added samples
[windows-sources.git] / sdk / samples / WCFSamples / TechnologySamples / Extensibility / Metadata / CustomMexEndpoint / CS / SvcutilClient / client.cs
blobf06263ae2cebaf0d5ec41539365f9e556833b1e7
2 // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 using System;
5 using System.ServiceModel;
6 using System.ServiceModel.Description;
7 using System.Collections.ObjectModel;
8 using System.Security.Cryptography.X509Certificates;
9 using System.ServiceModel.Channels;
10 using System.ServiceModel.Security;
12 namespace Microsoft.ServiceModel.Samples
14 //The service contract is defined in generatedCalculatorService.cs, generated from the service by the svcutil tool.
16 //Client implementation code.
17 class Client
19 static void Main()
21 // Create a proxy with given client endpoint configuration
22 CalculatorClient client = new CalculatorClient();
24 // set the certificate on the client
25 client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My,
26 X509FindType.FindBySubjectName, "client.com");
27 client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust;
30 // Call the GetCallerIdentity service operation
31 Console.WriteLine(client.GetCallerIdentity());
33 // Call the Add service operation.
34 double value1 = 100.00D;
35 double value2 = 15.99D;
36 double result = client.Add(value1, value2);
37 Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);
40 // Call the Subtract service operation.
41 value1 = 145.00D;
42 value2 = 76.54D;
43 result = client.Subtract(value1, value2);
44 Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);
46 // Call the Multiply service operation.
47 value1 = 9.00D;
48 value2 = 81.25D;
49 result = client.Multiply(value1, value2);
50 Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);
52 // Call the Divide service operation.
53 value1 = 22.00D;
54 value2 = 7.00D;
55 result = client.Divide(value1, value2);
56 Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);
58 //Closing the client gracefully closes the connection and cleans up resources
59 client.Close();
61 Console.WriteLine();
62 Console.WriteLine("Press <ENTER> to terminate client.");
63 Console.ReadLine();