c# problem with authentication

I try to use FlightXML in MS .NET (C#, Visual Studio 2010).
I add Service Reference with WSDL URL flightxml.flightaware.com/soap/FlightXML2/wsdl
And then I write simple code



            var conn = new FlightXML2.FlightXML2SoapClient();

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

            conn.Open();
            Console.WriteLine( conn.Metar("KAUS") );
            conn.Close();


But I have authentication error, when program calls Metar method.



The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm="FlightXML2"'.


Where is the problem? :confused:

Be sure you are using the FlightXML API key and not your website password. The API key is a long hexadecimal string.

Yes, I am sure, I use my site login and key.
I have generated two keys, the first with “FlightAware Base Flight Tracking Data” access, the second with “FlightAware Base Flight Tracking Data + Airline Schedules, Gate Assignments, and Gate Times + Australian Airspace”. I have tried both keys, in c# it doesn’t work, but in JS sample it works normally.

Have you tried building the stubs by manually running the wsdl.exe utility and passing the credentials as described on our documentation page? I think there are limitations with simply adding the WSDL to Visual Studio as a service reference.

flightaware.com/commercial/fligh … ation2.rvt

This is how I got it working. :slight_smile: