# can't call methods with asp

**URL:** <https://discussions.flightaware.com/t/cant-call-methods-with-asp/12912>\
**Category:** AeroAPI\
**Created:** [June 11, 2012, 1:43am UTC](https://discussions.flightaware.com/t/cant-call-methods-with-asp/12912 "2012-06-11T01:43:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cime63](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@cime63](https://discussions.flightaware.com/u/cime63)\
**Post date:** [June 11, 2012, 1:43am UTC](https://discussions.flightaware.com/t/cant-call-methods-with-asp/12912/1 "2012-06-11T01:43:14Z")

</div>

```auto

		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.

---

<div class="post-metadata">

**Author:** ![bovineone](https://sea1.discourse-cdn.com/flex019/user_avatar/discussions.flightaware.com/bovineone/32/117631_2.png) [@bovineone](https://discussions.flightaware.com/u/bovineone)\
**Post date:** [June 11, 2012, 5:29pm UTC](https://discussions.flightaware.com/t/cant-call-methods-with-asp/12912/2 "2012-06-11T17:29:56Z")

</div>

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](https://github.com/douglascrockford/JSON-js)

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

```auto

<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
%>

```

---

<div class="post-metadata">

**Author:** ![cime63](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@cime63](https://discussions.flightaware.com/u/cime63)\
**Post date:** [June 12, 2012, 1:11am UTC](https://discussions.flightaware.com/t/cant-call-methods-with-asp/12912/3 "2012-06-12T01:11:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bovineone](https://sea1.discourse-cdn.com/flex019/user_avatar/discussions.flightaware.com/bovineone/32/117631_2.png) [@bovineone](https://discussions.flightaware.com/u/bovineone)\
**Post date:** [June 12, 2012, 2:01am UTC](https://discussions.flightaware.com/t/cant-call-methods-with-asp/12912/4 "2012-06-12T02:01:52Z")

</div>

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](https://flightaware.com/commercial/flightxml/key) and entering your billing information if prompted.

---

<div class="post-metadata">

**Author:** ![cime63](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@cime63](https://discussions.flightaware.com/u/cime63)\
**Post date:** [June 12, 2012, 2:09am UTC](https://discussions.flightaware.com/t/cant-call-methods-with-asp/12912/5 "2012-06-12T02:09:00Z")

</div>

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](http://flightaware.com)), then I can try to get the key of myself.

And I donwnload c# and javascript sample code from [flightaware.com](http://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

---

<div class="post-metadata">

**Author:** ![cime63](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@cime63](https://discussions.flightaware.com/u/cime63)\
**Post date:** [June 12, 2012, 3:53am UTC](https://discussions.flightaware.com/t/cant-call-methods-with-asp/12912/6 "2012-06-12T03:53:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cime63](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@cime63](https://discussions.flightaware.com/u/cime63)\
**Post date:** [June 12, 2012, 3:55am UTC](https://discussions.flightaware.com/t/cant-call-methods-with-asp/12912/7 "2012-06-12T03:55:38Z")

</div>

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
