![MACROMEDIA FLASH REMOTING MX Use Manual Download Page 115](http://html1.mh-extra.com/html/macromedia/flash-remoting-mx/flash-remoting-mx_use-manual_687566115.webp)
Calling web services from Flash Remoting
115
Calling web services from Flash Remoting
Using Flash Remoting 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.
Invoking web service methods using Flash Remoting
The following example shows an example of a Service constructor for accessing a web service:
import mx.remoting.Service;
//…
var myWebService:Service = new Service(
"http://localhost/flashservices/gateway",
null,
"URL_to_WSDL",
null,
null);
The Service constructor specifies the Flash Remoting service URL in ColdFusion and creates a
reference to the web service. No connection to ColdFusion is made until you make the service
function call.
The following example Service constructor references a petmarket web service, located at http://
examples.macromedia.com/flashservices/gateway, which returns a list of categories to display in a
DataGrid component:
var petMarketService:Service = new Service(
"http://examples.macromedia.com/flashservices/gateway",
new Log(),
"petmarket.api.catalogservice",
null,
null);
After you establish the gateway, you can call methods of the web service.
The petmarket web service contains a method named
getCategories()
. This method takes a
string that specifies a language and returns a RecordSet object containing categories.
var temp_pc:PendingCall = petMarketService.getCategories("en_US");
temp_pc:responder = new
RelayResponder(this,"getCategories_Result","getCategories_Fault");