can't call methods with asp



		sUrl = "http://flightxml.flightaware.com/soap/FlightXML2/FlightInfo"
		data = "ident=AA59&howMany=1&offset=0"
		sUser = "sss"
		sKey = "ttt"
		
		Set XmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
	    XmlHttp.Open "Post", sUrl, false

	   
	    XmlHttp.SetRequestHeader "Content-Type", "application/xml; charset=UTF-8"
	    'XmlHttp.SetRequestHeader "Accept", "application/xml; charset=UTF-8"
		xmlhttp.setRequestHeader "Content-Length", Len(data)
		xmlhttp.SetRequestHeader "Authorization", "Basic " & Base64Encode(sUser & ":" & sKey )
	    XmlHttp.Send(data)

		'response.write(XmlHttp.ResponseText)
		'response.ContentType ="text/plain"
		if XmlHttp.Status = 200 then
			Response.Write XmlHttp.responseXML.xml
		else
			response.write "Status:" & XmlHttp.Status & "<br/>"
			Response.Write "Info:" & XmlHttp.ResponseText
		end if


call methods with above code, but can’t works. Show following info:

Method Not Implemented
Post to /soap/FlightXML2/FlightInfo not supported.

Anyone can help me?

Thanks & best regards.

SOAP requests must use /soap/FlightXML2/op as the endpoint, and the request must be encoded as an XML document in the standard SOAP request body format.

I recommending using the JSON interface to FlightXML instead, if you are needing to generate and parse the bodies manually.

Download the json2.js parser from Douglas Crockford’s JSON in JavaScript project at github.com/douglascrockford/JSON-js

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



<script language="javascript" runat="server" src="json2.js"></script>
<%
Dim postData, httpRequest, jsonResponse

postData = "airport=KAUS"
postData = postData & "&howMany=10"
postData = postData & "&filter=airline"

Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
httpRequest.Open "POST", "http://flightxml.flightaware.com/json/FlightXML2/Arrived", False, "YOUR_USERNAME", "YOUR_APIKEY"
httpRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpRequest.Send postData

If httpRequest.status = 200 Then
    Set jsonResponse = JSON.parse(httpRequest.responseText)

    For Each flight In jsonResponse.ArrivedResult.arrivals
        Response.Write("Flight " & flight.ident & " is arriving from " & flight.origin & "<br>") 
    Next
Else
    Response.Write("Error occurred")
End If

Set httpRequest = Nothing
%>


Sir,
Thank you very much for your reply first.

Just I have a questions, are you sure it can works?

I ask this is because I download all codes and run it, it show me following:
httpRequest.status: 401
httpRequest.ResponseText: Authentication Required

I don’t know why that happen, is that possible is caused of the wrong username or api key?

Thanks & best regards.

That code is untested, so it may or may not work but I suspect it’s very close to being complete.

However, you need to ensure that you are using a FlightXML API key and not your website password. If you do have an API key, you can sign up for one by visiting flightaware.com/commercial/flightxml/key and entering your billing information if prompted.

Sir,
Thanks very much for your reply.
I wrote this code for others, the employer send me the apikey and username. He said that’s right.

I don’t want to create apikey for myself, because I don’t need the serivice. If I can cancle the apikey(and the credit card info from flightaware.com), then I can try to get the key of myself.

And I donwnload c# and javascript sample code from flightaware.com, they all can’t works with the username and apikey, and show the same wrong info.

Maybe it is caused by the wrong username or apikey? Maybe~~~~~~~ I don’t know how to ensure that.

Anyway, thanks very much for your reply again.

Thanks & best regards,
— zhangkai

Hi Sir,
good news!!
I create a key of myself, and the code work great now!

So that issue is caused by the wrong username or apikey.

thanks very much for your help!

Thanks & best regards,
—zhangkai

get the result like following:

Flight AAL2491 is arriving from KORD
Flight SWA367 is arriving from KPHX
Flight UAL272 is arriving from KIAD
Flight UAL1234 is arriving from KIAH
Flight AAL1452 is arriving from KDFW
Flight FLG3477 is arriving from KMEM
Flight UPS301 is arriving from MMMY
Flight AAL1202 is arriving from KDFW
Flight ASH2653 is arriving from KCLT
Flight SKW5301 is arriving from KORD