Flash Remoting and Web Services : Retrieving Stock Quote Information
This is a simple Flash example that calls a Stock quote web service via Flash Remoting. You can find more info on the web service being used below at xmethods.net.
- Download and install the ColdFusion MX preview release.
- Download and install the Flash Remoting add-ons for Flash MX.
- Create a new Flash movie and enter the the following code in the first frame of the movie.
#include "NetServices.as"
var params = new Object();
//this is always 0, and is specific to the web service.
params.LicenseKey = "0″;
//stock symbol we want information about
params.StockSymbol = "macr";
//create an object to catch the response from the web service
var result = new Object();
//data is an object which contains properties with information about the stock.
result.onResult = function(data)
{
//loop through all of the properties and print them out
for(var x in data)
{
trace(x + " : " + data[x]);
}
}
//this gets called if an error occurs.
result.onStatus = function(error)
{
//print out the error
trace("Error : " + error.description);
}
//the path to the web service’s WSDL file.
var webServiceWSDL = "http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?wsdl";
var gw = NetServices.createGatewayConnection("http://localhost:8500/flashservices/gateway/");
var service = gw.GetService(webServiceWSDL, result);
//call a method on the web service, passing params.
service.GetQuote(params);
Test the movie. You should see the data from the web service print in the Output window.