All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Using .net 4
PostPosted: Mon Sep 09, 2013 2:58 pm 
Offline
averyjkraft - FlightAware user avatar

Joined: Wed Aug 18, 2010 9:00 am
Posts: 3
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


Top
 Profile  
 
 Post subject: Re: Using .net 4
PostPosted: Mon Sep 09, 2013 3:08 pm 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1434
Location: FlightAware WHQ
Did you try running the wsdl.exe command to generate the interface files from the WSDL first?


Top
 Profile  
 
 Post subject: Re: Using .net 4
PostPosted: Mon Sep 09, 2013 4:39 pm 
Offline
averyjkraft - FlightAware user avatar

Joined: Wed Aug 18, 2010 9:00 am
Posts: 3
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


Top
 Profile  
 
 Post subject: Re: Using .net 4
PostPosted: Mon Sep 09, 2013 4:46 pm 
Offline
averyjkraft - FlightAware user avatar

Joined: Wed Aug 18, 2010 9:00 am
Posts: 3
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 http://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


Top
 Profile  
 
 Post subject: Re: Using .net 4
PostPosted: Mon Sep 09, 2013 4:52 pm 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1434
Location: FlightAware WHQ
The structs are generated when you run this command:
Code:
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.


Top
 Profile  
 
 Post subject: Re: Using .net 4
PostPosted: Fri Sep 13, 2013 5:00 pm 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1434
Location: FlightAware WHQ
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?


Top
 Profile  
 
 Post subject: Re: Using .net 4
PostPosted: Thu Feb 23, 2017 5:02 am 
Offline
AndrewSynnott - FlightAware user avatar

Joined: Fri Feb 10, 2017 11:52 am
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: Using .net 4
PostPosted: Thu Feb 23, 2017 11:47 am 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 1434
Location: FlightAware WHQ
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.


Top
 Profile  
 
 Post subject: Re: Using .net 4
PostPosted: Fri Feb 24, 2017 5:41 am 
Offline
AndrewSynnott - FlightAware user avatar

Joined: Fri Feb 10, 2017 11:52 am
Posts: 2
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 http://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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron