All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Please Help: Having issues getting C# Example to work
PostPosted: Thu Jul 13, 2017 10:57 am 
Offline
qnguyenvt - FlightAware user avatar

Joined: Mon Jun 12, 2017 1:04 pm
Posts: 1
Hi, I followed the C# Example verbatim on Visual Studio 2015 - I added the service reference https://flightxml.flightaware.com/soap/FlightXML2/wsdl), copied the code over using my username and API Key, and got everything compiling. However, I am getting the following error when I execute the test method:

System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at https://flightxml.flightaware.com/soap/FlightXML2/wsdl that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
System.Net.WebException: Unable to connect to the remote serverSystem.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Anyone have any ideas?

Here is a cut and paste of my code:

app.config:

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="FlightXML2Soap" useDefaultWebProxy="false">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://flightxml.flightaware.com/soap/FlightXML2/op"
binding="basicHttpBinding" bindingConfiguration="FlightXML2Soap"
contract="FlightXML2.FlightXML2Soap" name="FlightXML2Soap" />
</client>
</system.serviceModel>

C# Code:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Atsg.Tests.FlightXML2;

namespace Atsg.Tests.Web
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
FlightXML2SoapClient client = new FlightXML2SoapClient();
client.ClientCredentials.UserName.UserName = "MyUserName";
client.ClientCredentials.UserName.Password = "MyApiKey";

EnrouteStruct r = client.Enroute("KHOU", 10, "", 0);
foreach (EnrouteFlightStruct e in r.enroute)
{
Console.WriteLine(e.ident);
}

Console.WriteLine(client.Metar("KAUS"));
}
}
}


Top
 Profile  
 
 Post subject: Re: Please Help: Having issues getting C# Example to work
PostPosted: Wed Jul 19, 2017 9:35 pm 
Offline
FlightAware Staff
conej730 - FlightAware user avatar

Joined: Sat Sep 13, 2008 11:00 pm
Posts: 97
I don't see any issues with the code and app.config. It seems like perhaps there is an issue with the connection itself? If you're able to browse the Connected Services and see the endpoints then the WSDL was successfully pulled down. The only difference between my app.config is that I'm not specifying useDefaultWebProxy. Perhaps though someone on the forums is more of a .NET person and may have an idea.

Have you tried just setting up a REST Client instead of using the SOAP interface? We have a dotnetcore example using a REST client for FlightXML3. https://github.com/flightaware/flightxm ... dotnetcore

You could modify the URL to call FlightXML2 instead.


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

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users 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: