Connecting to a Web Service in Flash

There were several unanswered threads from a long time ago that dealt with accessing a web service using Flash. The following takes a web service I created in my ASP.NET web service tutorial and displays the information in Flash:

import mx.services.WebService;
import mx.services.PendingCall;
function WebServiceCall(input:Number) {
 var returnedValue:String;
 var wsURL:String = "http://www.kirupafx.com/WebService/TopMovies.asmx?WSDL";
 var ws:WebService = new WebService(wsURL);
 var re:PendingCall = ws.GetMovieAtNumber(input);
 re.onResult = function(result):Void  {
  returnedValue = result;
  trace("Value returned: "+returnedValue);
 };
 re.onFault = function(fault) {
  returnedValue = fault.faultCode+","+fault.faultstring;
  trace(returnedValue);
 };
}
// 5 corresponds to "Schindler's List"
WebServiceCall(5);

Hopefully this is helpful. This will definitely be expanded into a tutorial at a later time :slight_smile:

Cheers!
Kirupa :inc: