Exemplo n.º 1
0
 private void ButtonGetStartTime_Clicked(object sender, RoutedEventArgs e)
 {
     try
     {
         NetTcpBinding bind = new NetTcpBinding(SecurityMode.Transport);
         //String url = "net.tcp://localhost:7103/WCFTestService";
         bind.Security.Mode = SecurityMode.Transport;
         bind.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;
         String          url  = ConfigurationManager.AppSettings["ServerDataURL"];
         EndpointAddress addr = new EndpointAddress(url);
         ChannelFactory <ITestInterface> chn = new ChannelFactory <ITestInterface>(bind, addr);
         chn.Credentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.TrustedPeople,
                                                          X509FindType.FindBySubjectName, "OlegClient");
         ITestInterface conn = chn.CreateChannel();
         var            res  = conn.GetStartTime();
         TextBoxStartTime.Text = res.StartTime.ToString();
     }
     catch (Exception ex)
     {
     }
 }