예제 #1
0
        public MainPage()
        {
            this.InitializeComponent();

            try
            {
                BasicHttpBinding binding = new BasicHttpBinding();

                binding.MaxBufferSize          = int.MaxValue;
                binding.ReaderQuotas           = System.Xml.XmlDictionaryReaderQuotas.Max;
                binding.MaxReceivedMessageSize = int.MaxValue;
                binding.AllowCookies           = true;

                binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

                EndpointAddress endpoint = new EndpointAddress("http://flightxml.flightaware.com/soap/FlightXML3/op");

                FlightXML3SoapClient client = new FlightXML3SoapClient(binding, endpoint);

                client.ClientCredentials.UserName.UserName = "******";
                client.ClientCredentials.UserName.Password = "******";

                FlightInfoStatusResponse response = client.FlightInfoStatusAsync("VA912", false, "", 1, 0).Result;

                foreach (var flight in response.FlightInfoStatusResult.flights)
                {
                    tblFlightCode.Text   = flight.ident;
                    tbDepartureTime.Text = flight.estimated_departure_time.time;
                    tbOrigin.Text        = flight.origin.airport_name;
                    tbDestination.Text   = flight.destination.airport_name;
                    tbArrivalTime.Text   = flight.estimated_arrival_time.time;
                    tbAircraft.Text      = flight.aircrafttype;

                    //tblFlightCode.Text = $"{flight.ident} ({flight.aircrafttype})\t{flight.origin.airport_name}  Est Arrival {flight.estimated_arrival_time.time}";
                }
            }
            catch (Exception ex)
            {
                tblFlightCode.Text = $"Error {ex.Message}";
            }
        }
        static void Main(string[] args)
        {
            FlightXML3SoapClient client = new FlightXML3SoapClient();

            client.ClientCredentials.UserName.UserName = "******";
            client.ClientCredentials.UserName.Password = "******";

            AirportBoardsRequest req = new AirportBoardsRequest();

            req.airport_code = "KIAH";

            AirportBoardsStruct res = client.AirportBoards("KIAH", false, "", "enroute", 10, 0);

            Console.WriteLine("Flights enroute to KIAH");

            foreach (var flight in res.enroute.flights)
            {
                Console.WriteLine(String.Format("{0} ({1})\t{2} ({3})", flight.ident, flight.aircrafttype,
                                                flight.origin.airport_name, flight.origin.code));
            }
        }