Example #1
0
 //Initialize and connect to ATC Biz Controller master.
 public RouteConverter()
 {
     try //Create connection to Server.
     {
         DuplexChannelFactory <IATCBizControllerMaster> factory;
         NetTcpBinding tcpBinding = new NetTcpBinding();
         tcpBinding.MaxReceivedMessageSize      = System.Int32.MaxValue; //Change max message & array size.
         tcpBinding.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;
         string sURL = "net.tcp://localhost:50001/ATCBiz";
         factory = new DuplexChannelFactory <IATCBizControllerMaster>(new dummyCallback(), tcpBinding, sURL);
         IATCBizControllerMaster ATCBiz = factory.CreateChannel(); //Create connection.
         m_airports = ATCBiz.GetAirports();
         m_routes   = ATCBiz.GetAllRoutes();
     }
     catch (FaultException ex) //SOAP fault.
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
     catch (CommunicationException ex) //Communication error.
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
     catch (TimeoutException ex) //Server likely has died or halted.
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
     catch (Exception ex) //Generic exception for unknown problem.
     {
         System.Diagnostics.Debug.WriteLine("Exception type: " + ex.GetType());
         System.Diagnostics.Debug.WriteLine("Exception message: " + ex.Message);
     }
 }