Handling service results and errors
43
Note:
Calling web services using Flash Remoting is supported only in Flash Remoting for ASP.Net
and in the Flash Remoting support included with ColdFusion MX. Flash Remoting for Java and the
Flash Remoting support in JRun do not support calling web services using Flash Remoting.
Calling functions using named arguments in ColdFusion
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, see
“Passing parameters to ColdFusion components”
on page 106
.
Handling service results and errors
When you call a service function, there are two possible outcomes: the result that you expect or a
fault (error). These outcomes are relayed to a result handler method and an error handler method,
respectively, which you specify. For example, a result handler could display the results in the Flash
application, while an error handler might call trace functions to report the error descriptions. You
can specify the result and fault handling methods either for all results and faults that occur for the
service or for specific server function calls.
In both cases, you specify a responder object. The responder object can be any ActionScript
object that implments the mx.rpc.Responder interface. The Responder interface exposes two
methods (
onResult()
and
onFault()
) that respond to the results and faults for the current
pending call. For convenience Flash Remoting API provides an implementation of the mx.rpc.
Responder interface that you can use: mx.rpc.RelayResponder.
The RelayResponder relays any result and fault responses to any object and any method of that
object. To specify the methods that handle the result and the fault conditions, the constructor for
the RelayResponder object has, as its second and third parameters, the names of the methods that
handle the ResultEvent and FaultEvent objects that the service method returns. The first
parameter specifies the name of the object that contains these methods. For example, the
RelayResponder in the HelloWorld example specifies that the result handling method is
helloWorld_Result()
, the fault handling method is
helloWorld_Fault()
, and the class that
contains them is this class (this).
pc.responder = new RelayResponder( this, "helloWorld_Result",
"helloWorld_Fault" );
Note:
Do not specify result handler and fault handler methods when you create the service object
and
when you call a service function. Specifying methods in both places can cause errors in your
application that might be difficult to diagnose.
ColdFusion pages (.cfm)
ColdFusion page (without the cfm suffix)
ColdFusion components (.cfc)
Component method
Service type
Function name
Содержание FLASH REMOTING MX
Страница 1: ...Using Flash Remoting for Flash MX 2004 ActionScript 2 0...
Страница 8: ...8 Contents...
Страница 62: ...62 Chapter 3 Using the RemotingConnector component Flash Professional only...
Страница 142: ...142 Chapter 7 Using Flash Remoting for Java...