Esempio n. 1
0
 static void Main(string[] args)
 {
     try
     {
         string             serviceRepoAddress = ConfigurationSettings.AppSettings["serviceRepoAddress"];
         var                cf     = new ChannelFactory <IServiceRepository>(new NetTcpBinding(SecurityMode.None), new EndpointAddress(serviceRepoAddress));
         IServiceRepository serwis = cf.CreateChannel();
         serwis.RegisterService("serwis1", "adres_serwisu_1");
         serwis.RegisterService("serwis2", "adres_serwisu_2");
         Console.WriteLine(serwis.GetServiceLocation("serwis2"));
         System.Threading.Thread.Sleep(3000);
         serwis.Alive("serwis2");
         System.Threading.Thread.Sleep(3000);
         serwis.Alive("serwis2");
         System.Threading.Thread.Sleep(3000);
         serwis.Alive("serwis2");
         System.Threading.Thread.Sleep(3000);
         serwis.Alive("serwis2");
         Console.WriteLine(serwis.GetServiceLocation("serwis2"));
         Console.ReadLine();
     }
     catch (FaultException ex)
     {
         string msg = "FaultException: " + ex.Message;
         Console.WriteLine(msg);
         Console.ReadLine();
     }
 }