To call the functions exposed by a service object, you use the service object name followed by the application server functionality name. The following is an example:
weatherSvc.getTemperature("New York");
In this example, the getTemperature function exists in the application server as a public method or application page. The function also passes a string parameter, New York. To pass multiple parameters to service functions, you include a comma-separated list of values in the service function call; for example:
weatherSvc.getTemperature("New York", 1998, "average");
In this example, the service function passes three parameters, a city (New York), a year (1998), and a command (average).
Note: Parameters must be in the order required by the service function.
If you do not specify a result handler when you create the service object, you must specify a result-handler callback object for the service function when you call it. If you do specify a result handler when you create the service object, you must not specify a result-handler callback object for the service when you call it. Therefore, you must do either of the following:
Note: Do not specify a result handler both when you create the service object and when you call a service method. If you specify the result handler in both places, Flash Remoting MX passes an object representing the handler as the first argument to the service function. This will cause errors in your application that might be difficult to diagnose.
To specify a result handler for a specific service function call, add the result handler as the first entry in the function argument list, as in the following example:
weatherSvc.getTemperature( new temperatureResult(), "New York", 1998, "average" );
In this case, the temperatureResult result handler will receive and process the results, including any error status information, of the getTemperature service function.
For information on creating and using function-specific result handlers, see "Handling service results".
If you are calling a ColdFusion page or ColdFusion component that can take named arguments, you can also call a service function and pass it a single ActionScript object that contains name-value pairs for the arguments, as shown in the following example:
myService.myFunction( { dept: "Sales", name: "BobZ" });
The ColdFusion page or component uses the object elements, dept and name, as named arguments. For more information on passing parameters to ColdFusion, see "Passing parameters to ColdFusion components".
The way you specify the service function name depends on the type of service you are using. The following table lists how you specify the function names for the supported service types:
Note: Calling web services using Flash Remoting MX is only supported in Flash Remoting MX for .Net and in the Flash Remoting MX support included with ColdFusion MX. Flash Remoting MX for Java and the Flash Remoting MX support in JRun do not support calling web services using Flash Remoting MX.
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/UseActionScript6.htm