ColdFusion and DirectFlight

I am trying to develop an interface via ColdFusion. Do you know if anyone has ever tried to do that?? Is it even possible? I hope so. There is a custom tag called <CFX_SOAP>. This custom tag works great with other site I have used it for. I have some questions on getting started, but I will just wait for a reply on if anyone has tried this or if it is possible. Thanks, Chrissy

I know that ColdFusion is not part of our test suite at FlightAware, but I don’t know if any users are using it – very few report back on what language they’re using.

If you’re familiar with using SOAP and WSDL, you should be able to get your app to load the WSDL and start making calls to DirectFlight.

What are your questions? Maybe a knowledgeable person will pop up with the answer.

I am very proficient in ColdFusion, but unfortunately I am not in SOAP or WSDL. That is where my problem is at. Basically I am creating an array, then a substructure in the array with the variables that DirectFlight requires. Then I convert that object to WDDX format. That is done through a simple tag in ColdFusion. Question number one, can I just add in the username and key as additional fields in the object that is sent?

Here is the tag that I have started
<cfx_soap params=“#wddxString#”
URL=“http://flightaware.com/commercial/directflight/data/wsdl1.xml
URI=“I dont know what goes here. HELP”
METHOD=“FlightInfo”
OUTPUT=“Flights”>

I’m not familiar with ColdFusion, but checking Google, I found examples like:



<cfinvoke 
  webservice = "http://some.wsdl"
  returnVariable = "foo"
  ...
  username="aName"
  password="aPassword">
<cfoutput>#foo#</cfoutput>


I know that this is quite an old thread, but in case anyone is searching for a ColdFusion example, here’s how I did it:



<cfinvoke 
  webservice="http://flightaware.com/commercial/flightxml/data/wsdl1.xml" 
  method="enroute" 
  returnvariable="aEnrouteStruct" 
  username="flightxmlusername"
  password="flightxmlkey">
    <cfinvokeargument name="airport" value="KSFO"/>
    <cfinvokeargument name="howMany" value="15"/>
    <cfinvokeargument name="filter" value=""/>
    <cfinvokeargument name="offset" value="0"/>
</cfinvoke>
<cfset EnrouteFlights = aEnrouteStruct.getEnroute()>

Then you can output the elements of the EnrouteFlights array by using EnrouteFlights*.ident, EnrouteFlights*.aircrafttype and so on inside of tags. The other functions are very similar.

–Dev444**

Any other coldfusion folks using this that can help?

No matter what I do I get the following error.

Cannot perform web service invocation enroute.
The fault returned when invoking the web service operation is:

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
faultActor:
faultNode:
faultDetail:
{WebServices - Axis}stackTrace:org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configur… ‘’

my code is pretty normal.

<cfinvoke
webservice=“http://flightaware.com/commercial/flightxml/data/wsdl1.xml
method=“FlightInfo”
username=“#username#”
password=“#password#”
ident=“AWE112”
howMany=“2”
returnVariable=“aFlightInfoStruct”

Any help is appreciated!
Thank you!

Your error says “Cannot perform web service invocation enroute” but the code you listed is for FlightInfo method. Are you sure there isn’t something buggy with your code?

I took your code and used my username/password and it worked fine. Did you double check your username and password?

dev444

Thank you for replying.
I apologize. I was testing 2 different pages out and gave you the error from one and the code from the other. Both get the same error

The error I gave was from your example above.



 <cfinvoke
  webservice="http://flightaware.com/commercial/flightxml/data/wsdl1.xml"
  method="enroute"
  returnvariable="aEnrouteStruct"
  username="#username#"
  password="#password#">
    <cfinvokeargument name="airport" value="KSFO"/>
    <cfinvokeargument name="howMany" value="15"/>
    <cfinvokeargument name="filter" value=""/>
    <cfinvokeargument name="offset" value="0"/>
</cfinvoke>
<cfset EnrouteFlights = aEnrouteStruct.getEnroute()>


I grabbed a new api key this morning and tried again and same error.
I also deleted the web service in coldfusion admin before I tried so it would remake itself.

For giggles I tested this on a different server and same result.
Both servers are CF 8.

For laughs I took out my user name and password, deleted the web service and I got the following which tells me I am at least authenticating properly with my username and password.

AxisFault
faultCode: {WebServices - Axis}HTTP
faultSubcode:
faultString: (401)Authorization Required

I have never used cfinvoke before this but I did test it to work successfully yesterday using a weather site



 <cfinvoke
 webservice="http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl"
 method="GetCityForecastByZIP"
 zip="15222"
 returnVariable="GetCityForecastByZIPResponse"
>
<cfdump var="#GetCityForecastByZIPResponse#" expand="No"><br>
<cfdump var="#GetCityForecastByZIPResponse.getForecastResult()#" expand="No"><br>
<cfdump var="#GetCityForecastByZIPResponse.getForecastResult().getForecast()#" expand="No"><br>
<cfdump var="#GetCityForecastByZIPResponse.getForecastResult().getForecast(1)#" expand="No"><br>
 

I am beating my head into the wall trying to understand why I can’t pull from FlightXML.

Thanks again!

In the past, when FlightXML was causing me problems and my code hadn’t changed, I had to test the SOAP function to see what was being returned by FlightAware. I used the following SOAP client:

sourceforge.net/projects/soapui/

Try it out (remember to the put your FlightAware username and password in the right spot). See what you’re actually getting back from FlightAware. Maybe there’s an error with your username/password. When I changed my password, I got the same error response you did.

Dev444

that soapUI is a great find, thank you.
The soapUI works!

What version of coldfusion are you running?

CF8

I am trying to figure out how to write it differently to test it. using something other than cfinvoke

My username and password worked with soapUI.
But your code does not work for me?

I am wondering if there is something else going on here that I am just not aware of.

I found out how to turn on logging for soap requests and responses in coldfusion.

The problem really appears to be on flightaware’s end of things. here is what I got.

what the response gives me is



Server Error
Mon Jul 20 10:54:14 EDT 2009
The server encountered an internal error when handling your page. 

Tcl-Webserver/3.5.1 May 27, 2004
Tcl version 8.4.18 

  
Send email to webmaster@juliet.flightaware.com. 






:::SOAP Request:::

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<soapenv:Body>
		<ns1:FlightInfo soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="FlightAwareDirectFlight">
			<ident xsi:type="xsd:string">AWE112</ident>
			<howMany xsi:type="xsd:int">2</howMany>
		</ns1:FlightInfo>
	</soapenv:Body>
</soapenv:Envelope>


:::SOAP Response:::



<!Doctype HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<Html>
<Head>
<Title>Server Error</Title>
<!-- Author: bwelch -->
<META HTTP-Equiv=Editor Content="SunLabs WebTk 1.0demo 3/10/97">
</Head>
<Body>



<h1>Server Error</h1>
<h4>Mon Jul 20 10:54:14 EDT 2009</h4>
<p>
The server encountered an internal error when handling your page.
<p>
Tcl-Webserver/3.5.1 May 27, 2004<br>Tcl version 8.4.18
<p>
<form action=/mail/bugreport method=post>
<input type=hidden name=errorInfo value="can't read "user_id": no such variable
    while executing
"list $auth $id $user_id $accounttype $is_sua_customer"
    (procedure "flightaware_billing_directFlight_authenticate" line 28)
    invoked from within
"flightaware_billing_directFlight_authenticate $username $key"
    (procedure "DirectFlight_Authenticate" line 50)
    invoked from within
"DirectFlight_Authenticate sock11 /soap/DirectFlight/go"
    ("eval" body line 1)
    invoked from within
"eval $hook [list $sock $url]"">
<input type=hidden name=env value="STY 950.ttyp0.juliet HOME /usr/home/karl LOGNAME root PWD /usr/local/tclhttpd/custom MAIL /var/mail/karl SSH_CLIENT {216.52.171.95 63997 22} SUDO_UID 1001 SUDO_GID 1001 BLOCKSIZE K SSH_AUTH_SOCK /tmp/ssh-3vqK5JsPzP/agent.762 HTTP_CHANNEL sock11 CVS_RSH ssh WINDOW 0 FTP_PASSIVE_MODE YES TERM screen SHELL /usr/local/bin/bash CVSROOT cvs.flightaware.com:/usr/home/cvs SHLVL 4 SUDO_COMMAND {/usr/local/bin/tclsh8.4 /usr/local/bin/httpd.tcl -debug 1} SUDO_USER karl OLDPWD /usr/local/tclhttpd/custom PGCLIENTENCODING UNICODE SSH_CONNECTION {216.52.171.95 63997 216.52.171.102 22} PATH /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/usr/home/karl/bin TZ EST5EDT SSH_TTY /dev/ttyp0 _ /usr/local/bin/sudo EDITOR vi LC_ALL C USER root PAGER less">
<input type=hidden name=email value=webmaster@juliet.flightaware.com>
<input type=submit value="Submit auto bug report to webmaster@juliet.flightaware.com">
</form>
<p>
<p>
<form action=/debug/errorInfo method=post>
<input type=hidden name=errorInfo value="can't read "user_id": no such variable
    while executing
"list $auth $id $user_id $accounttype $is_sua_customer"
    (procedure "flightaware_billing_directFlight_authenticate" line 28)
    invoked from within
"flightaware_billing_directFlight_authenticate $username $key"
    (procedure "DirectFlight_Authenticate" line 50)
    invoked from within
"DirectFlight_Authenticate sock11 /soap/DirectFlight/go"
    ("eval" body line 1)
    invoked from within
"eval $hook [list $sock $url]"">
<input type=hidden name=env value="STY 950.ttyp0.juliet HOME /usr/home/karl LOGNAME root PWD /usr/local/tclhttpd/custom MAIL /var/mail/karl SSH_CLIENT {216.52.171.95 63997 22} SUDO_UID 1001 SUDO_GID 1001 BLOCKSIZE K SSH_AUTH_SOCK /tmp/ssh-3vqK5JsPzP/agent.762 HTTP_CHANNEL sock11 CVS_RSH ssh WINDOW 0 FTP_PASSIVE_MODE YES TERM screen SHELL /usr/local/bin/bash CVSROOT cvs.flightaware.com:/usr/home/cvs SHLVL 4 SUDO_COMMAND {/usr/local/bin/tclsh8.4 /usr/local/bin/httpd.tcl -debug 1} SUDO_USER karl OLDPWD /usr/local/tclhttpd/custom PGCLIENTENCODING UNICODE SSH_CONNECTION {216.52.171.95 63997 216.52.171.102 22} PATH /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/usr/home/karl/bin TZ EST5EDT SSH_TTY /dev/ttyp0 _ /usr/local/bin/sudo EDITOR vi LC_ALL C USER root PAGER less">
<input type=hidden name=title value="Error Info">
<input type=submit value="See the error info">
</form>
<p>
<a HREF=mailto:webmaster@juliet.flightaware.com>Send email to webmaster@juliet.flightaware.com</a>.
<p>
<a HREF="/index.html">Home</a>

</Body>
</Html>



07/20 10:54:14 Error [jrpp-1] - Cannot perform web service invocation FlightInfo.The fault returned when invoking the web service operation is:

AxisFault   faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException   faultSubcode:    faultString: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.   faultActor:    faultNode:    faultDetail:   	{WebServices - Axis}stackTrace:org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.  	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)  	at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)  	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)  	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)  	at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)  	at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)  	at org.ap… The specific sequence of files included or processed is: C:\Inetpub.Sites\intranet.lockheartlimo.com\htdocs\flights.cfm, line: 70




That is a (now corrected) bug during the handling of a failed authentication attempt – when the User ID / Key doesn’t match.

Would you mind sharing how to turn on logging? I think it could be very helpful.

dev444

dbaker
Thats what dev444 thought but my username/key works for me using the windows client ‘soapUI’ soapui.org/

I have deleted the cached web service almost every time I have tested to make sure it is not sending bad authentication.

I have tested this every which way I can think of including from multiple web servers, rewriting the code different ways and different methods, and testing using that windows client.

Is it possible I am sending something “corrupt” to the FlightXML and it is seeing it as bad authentication?

dev444
here is where I turned on logging for soap in cf8

coldfusionjedi.com/index.cfm … 827EB1B545

I had one of my guys do a test with perl and he also got a bug error back and his complains about a different variable than the bug I got.
The bug I got from the server complained about user_id, his complained about accounttype.

keep in mind, I dont know why, but using soapUI I am able to pull flight info

I don’t see why I am getting ‘server encountered an internal error’ when using either coldfusion or perl, I was trying php as well but I dont know enough about it

is there possibly something wrong with my account thats causing the error to be thrown for some reason?



<h1>Server Error</h1>
<h4>Wed Jul 22 10:49:52 EDT 2009</h4>
<p>

The server encountered an internal error when handling your page.
<p>
Tcl-Webserver/3.5.1 May 27, 2004<br>Tcl version 8.4.18
<p>
<form action=/mail/bugreport method=post>
<input type=hidden name=errorInfo value="can't read "accounttype": no such variable
    while executing
"list $auth $id $user_id $accounttype $is_sua_customer"
    (procedure "flightaware_billing_directFlight_authenticate" line 29)
    invoked from within
"flightaware_billing_directFlight_authenticate $username $key"
    (procedure "DirectFlight_Authenticate" line 50)
    invoked from within
"DirectFlight_Authenticate sock7 /soap/DirectFlight/go"
    ("eval" body line 1)
    invoked from within
"eval $hook [list $sock $url]"">
<input type=hidden name=env value="STY 950.ttyp0.juliet HOME /usr/home/karl LOGNAME root PWD /usr/local/tclhttpd/custom MAIL /var/mail/karl SSH_CLIENT {216.52.171.95 63997 22} SUDO_UID 1001 SUDO_GID 1001 BLOCKSIZE K SSH_AUTH_SOCK /tmp/ssh-3vqK5JsPzP/agent.762 HTTP_CHANNEL sock7 CVS_RSH ssh WINDOW 0 FTP_PASSIVE_MODE YES TERM screen SHELL /usr/local/bin/bash CVSROOT cvs.flightaware.com:/usr/home/cvs SHLVL 4 SUDO_COMMAND {/usr/local/bin/tclsh8.4 /usr/local/bin/httpd.tcl -debug 1} SUDO_USER karl OLDPWD /usr/local/tclhttpd/custom PGCLIENTENCODING UNICODE SSH_CONNECTION {216.52.171.95 63997 216.52.171.102 22} PATH /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/usr/home/karl/bin TZ EST5EDT SSH_TTY /dev/ttyp0 _ /usr/local/bin/sudo EDITOR vi LC_ALL C USER root PAGER less">
<input type=hidden name=email value=webmaster@juliet.flightaware.com>
<input type=submit value="Submit auto bug report to webmaster@juliet.flightaware.com">
</form>
<p>
<p>
<form action=/debug/errorInfo method=post>
<input type=hidden name=errorInfo value="can't read "accounttype": no such variable
    while executing
"list $auth $id $user_id $accounttype $is_sua_customer"
    (procedure "flightaware_billing_directFlight_authenticate" line 29)
    invoked from within
"flightaware_billing_directFlight_authenticate $username $key"
    (procedure "DirectFlight_Authenticate" line 50)
    invoked from within
"DirectFlight_Authenticate sock7 /soap/DirectFlight/go"
    ("eval" body line 1)
    invoked from within
"eval $hook [list $sock $url]"">
<input type=hidden name=env value="STY 950.ttyp0.juliet HOME /usr/home/karl LOGNAME root PWD /usr/local/tclhttpd/custom MAIL /var/mail/karl SSH_CLIENT {216.52.171.95 63997 22} SUDO_UID 1001 SUDO_GID 1001 BLOCKSIZE K SSH_AUTH_SOCK /tmp/ssh-3vqK5JsPzP/agent.762 HTTP_CHANNEL sock7 CVS_RSH ssh WINDOW 0 FTP_PASSIVE_MODE YES TERM screen SHELL /usr/local/bin/bash CVSROOT cvs.flightaware.com:/usr/home/cvs SHLVL 4 SUDO_COMMAND {/usr/local/bin/tclsh8.4 /usr/local/bin/httpd.tcl -debug 1} SUDO_USER karl OLDPWD /usr/local/tclhttpd/custom PGCLIENTENCODING UNICODE SSH_CONNECTION {216.52.171.95 63997 216.52.171.102 22} PATH /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/usr/home/karl/bin TZ EST5EDT SSH_TTY /dev/ttyp0 _ /usr/local/bin/sudo EDITOR vi LC_ALL C USER root PAGER less">
<input type=hidden name=title value="Error Info">

<input type=submit value="See the error info">
</form>
<p>
<a HREF=mailto:webmaster@juliet.flightaware.com>Send email to webmaster@juliet.flightaware.com</a>.
<p>
<a HREF="/index.html">Home</a>



Your account is fine, I think you’re just making malformed requests. The following code works with any of your 3 keys.


<?php

	require_once('SOAP/Client.php');

	$DirectFlight_Authentication = array(
		'user'		=> 'shamrocklimo',
		'pass'		=> 'key starting with 65a5...',
	);

	$wsdl_url = 'http://directflight.flightaware.com/soap/DirectFlight/wsdl';
	$WSDL = new SOAP_WSDL($wsdl_url,$DirectFlight_Authentication);
	$soap = $WSDL->getProxy();

	print "<pre>";
	$result = $soap->Search('-idents HAL*',15,0);
	print_r($result);
	print "</pre>";

php?>

Thanks! We got it

I wonder if your CF code is changing your password or username. Are there any special characters in it? Personally, I just type my username/password directly into the code without using a variable and surrounding it with pound signs. But maybe that’s the issue with CF?

dev444