Using Flash Remoting MX with ColdFusion, you can interact with web services directly from your Flash applications without having to build a ColdFusion page or component. You write the code to reference a web service in your Flash application and use ColdFusion only to perform the access.
Web services are remote applications that expose their functions and associated parameters using the Web Services Description Language (WSDL). WSDL files describe the functionality of a web service, including available functions, parameters, and results. You use a Simple Object Access Protocol (SOAP) proxy to parse the WSDL and make the remote service functions available in your application.
ColdFusion MX contains a built-in SOAP proxy for interacting with web services. The ColdFusion Flash Remoting service also includes a web service adapter, which employs the ColdFusion SOAP proxy for calling methods, passing parameters, and returning results from web services. Using the ColdFusion SOAP proxy, much of the complexity associated with programming web services is removed.
The following example shows the code you use to access a web service:
#include "NetServices.as"
if (inited == null)
{
// do this code only once
inited = true;
NetServices.setDefaultGatewayUrl("http://localhost/flashservices/gateway");
gateway_conn = NetServices.createGatewayConnection();
myWebService = gateway_conn.getService("URL_to_WSDL", this);
}
The setDefaultGatewayUrl function specifies the Flash Remoting service URL in ColdFusion. The getService function creates a reference to the web service. No connection to ColdFusion is made until you make the service function call.
The following example getService function references a temperature web service, located at http://www.xmethods.net/sd/2001/TemperatureService.wsdl, which returns the local temperature by U.S. zip code:
myWebService = gateway_conn.getService("http://www.xmethods.net/sd/2001/TemperatureService.wsdl", this);
Once you create the connection, you can call methods of the web service.
The temperature web service contains a single method named getTemp. This method takes a string containing a zip code and returns the temperature as a float. The following code assumes that inzip represents an input text field:
myWebService.getTemp(inzip.text);
To handle the results of the web service method, you create an event handler with the same name as the service functions with _Result or _Status appended to the name. The result handler displays the results in the translate input text box, as the following example shows:
function getTemp_Result(result)
{
tempDisplay.text = result;
}
function getTemp_Status(result)
{
tempDisplay.text = error.description;
}
In this example, the result of the web service function call, represented by the result variable, is assigned to the text property of the text box tempDisplay, which displays in the Flash application.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flashremoting/mx/Using_Flash_Remoting_MX/usingFRCF5.htm
Comments
No screen name said on Feb 21, 2004 at 4:00 PM : carehart said on Nov 4, 2004 at 9:54 PM :