Using .net 4

We are using C# to access Flight Aware soap API but the .net example is way out of date. i’m using VS 2012 and .Net 4 so the structs your example shows don’t exist.
can someone give me a C# VS2012 .Net 4 sample? Kevin

Did you try running the wsdl.exe command to generate the interface files from the WSDL first?

The code examples for C# are true for .net 2 and not to .net 4 as we are using. Windows has advanced greatly since Win 95 and unless we can use FlightAware with latest Windows (7 & 8) it will be difficult to use your data feed.

Avery

Look at the posted example and let me know how it can help us write the interface:

Examples (SOAP / WSDL)

Microsoft .NET

Hide example (C#)…

Any Microsoft CLR .NET language should be usable to make requests to FlightXML 2.0, however this example is using C#. The procedure for using other languages may vary slightly. The steps described here use the command-line utilities to generate the WSDL stub and compile, but the steps can be adapted for use within the Visual Studio IDE.
Requirements •Microsoft Visual Studio 2003 or newer

Save the following file as test.cs, but substitute your actual username and API key:

using System.Net;
class test {
public static void Main(string] args)
{
FlightXML2 df = new FlightXML2();
df.Credentials = new NetworkCredential(“sampleUser”, “abc123abc123abc123abc123abc123”);
df.PreAuthenticate = true;

    // get the flights currently enroute.
    EnrouteStruct r = df.Enroute("KAUS", 10, "", 0);
    foreach (EnrouteFlightStruct e in r.enroute) {
        System.Console.WriteLine(e.ident);
    }

    // get the weather.
    System.Console.WriteLine(df.Metar("KAUS"));
}

}

Run commands:

wsdl.exe flightxml.flightaware.com/soap/FlightXML2/wsdl

csc.exe test.cs FlightXML2.cs

test.exe

We are using C# to access FlightAware soap API and your .net example is way out of date. i’m using VS 2012 and .Net 4 so the structs your example shows don’t exist.
can you give me a C# VS2012 .Net 4 sample?
Avery

The structs are generated when you run this command:


wsdl.exe http://flightxml.flightaware.com/soap/FlightXML2/wsdl

Once you run that command, it will generate a FlightXML2.cs file that can be added to your project, which defines the structs.

Were these instructions enough to let you generate the interface structs and make requests? I see some FlightXML activity under your user account, so I assume it worked?

Is it possible to run the wsdl.exe command from somewhere other than the Developer Command Prompt or is there another way of creating FlightXML2.cs. Working from computer without administrator access so can’t create file a C:\Program Files (x86)\Microsoft Visual Studio 14.0

Thanks

You do not need to be an Administrator to run wsdl.exe It simply needs to be able to write files in the current directory that you run it from.

You probably do not want to change the current directory into the “C:\Program Files (x86)\Microsoft Visual Studio 14.0” directory, because that will make it write the generated files there.

You want to have your current directory be the location of your project, and then just run wsdl.exe either by having it in your PATH variable, or by specifying the full path to it.

Thanks very much - I was able to change the output location to my home drive by using (from Developer Command Prompt):
wsdl.exe /out:u:\FlightXML2.cs flightxml.flightaware.com/soap/FlightXML2/wsdl

and hey presto - I now have a cs file called FlightXML2.cs which I can add to my project (a Console Application).

When I built the Console Application, I had hundreds of missing references in FlghtXML2.cs - I think you need to add an extra reference to System.Web.Services.dll which is found in
C:\Program Files (x86)\ReferenceAssemblies\Microsoft\Framework.NETFramework\v4.6.1\System.Web.Services.dll

Then I wrote the program.cs file as follows - I’m looking to download recent flight data for a specific Tail number. Note reference to System.Net
Now to convert this into a DLL that I can call from Excel passing the TailID. Hope this helps someone - my first time using VisualStudio/C# - interesting stuff.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;

namespace ConsoleApplication8
{
class test
{
public static void Main(string] args)
{
FlightXML2 df = new FlightXML2();
df.Credentials = new NetworkCredential(“andrewsynnott”, “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”);
df.PreAuthenticate = true;

        // get the last 15 flights for a tailID using FlightInfoEx
        FlightInfoExStruct r = df.FlightInfoEx("N937NN", 15, 0);
        foreach (FlightExStruct t in r.flights)
            System.Console.WriteLine(t.actualdeparturetime + "  :  " + t.originCity + " to " + t.destinationCity);
            System.Console.Read();
    }
}

}

Thanks