static void Main(string[] args) { Console.WriteLine("Client"); var client = new ServiceReference1.ServiceClient("WSHttpBinding_IService"); // Productik p = new Productik(8, "KitKat", "Group10", 280); Productik p1 = new Productik(1, "KitKat", "Group10", 280); var result = client.StoreProduct(p1); Console.WriteLine("Message is {0}, status is {1}", result.Message, result.Status); Console.ReadKey(); }
static void Main(string[] args) { string val; ServiceReference1.ServiceClient test = new ServiceReference1.ServiceClient(); //MonService.ServiceClient test = new MonService.ServiceClient(); Console.WriteLine(test.GetMessage("Niko")); Console.WriteLine(test.GetResultOfAddition(1, 2)); val = Console.ReadLine(); test.SetTest(int.Parse(val)); Console.WriteLine(test.GetTest()); Console.ReadKey(); }
static void Main(string[] args) { try { // Binding Configurations WSHttpBinding communicationBinding = new WSHttpBinding(); communicationBinding.Security.Mode = SecurityMode.Transport; communicationBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate; CryptographyHelper cryptographyHelper = new CryptographyHelper(); X509Certificate2 serviceCertificate = cryptographyHelper.GetX509CertificateBySerialNumber(_ServiceCertSerial, StoreName.My, StoreLocation.LocalMachine); X509Certificate2 clientCertificate = cryptographyHelper.GetX509CertificateBySerialNumber(_ClientCertSerial);//from configiration // Create the endpoint address. EndpointAddress endpointAddress = new EndpointAddress(new Uri(_EndpointURL), EndpointIdentity.CreateX509CertificateIdentity(serviceCertificate)); // Call the client service // Client service class can generated from the WSDL file ServiceReference1.ServiceClient ws = new ServiceReference1.ServiceClient(communicationBinding, endpointAddress); // Specify a certificate to use for authenticating the client. ws.ClientCredentials.ClientCertificate.SetCertificate( StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySerialNumber, clientCertificate.SerialNumber); // Specify a default certificate for the service. ws.ClientCredentials.ServiceCertificate.SetDefaultCertificate( StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySerialNumber, serviceCertificate.SerialNumber); // Call the service ws.DoWork(); } catch (Exception ex) { Console.Write(ex.Message); } }