
This is the Title of the Book, eMatter Edition
Copyright © 2003 O’Reilly & Associates, Inc. All rights reserved.
32
|
Chapter 1: Introduction to Flash Remoting
server-side implementation. He need only know the API for the remote services he
intends to call. If he is using web services, he can query the .wsdl file on the server to
discover the methods. This allows both the server-side code and the Flash applica-
tion to be developed simultaneously, reducing production time and making testing
and debugging easier.
Even if one developer writes both the Flash and server-side code, the multitiered
architecture is still advantageous. It allows you to define an API, implement it on the
server, and then hook the Flash movie into it. This makes it possible to test each
component on its own before connecting Flash to the server, ensuring that bugs are
less frequent and easier to isolate.
Our example may seem simple, because we are only passing a string from the server
to Flash. However, if you think of a string as just another type of object or datatype,
you can begin to see the power of Flash Remoting. Try passing more complex
datatypes, such as an array, from the server-side service to Flash, and see what is
returned to the Flash movie. Modify the onResult( ) callback function from
Example 1-1 to do something more interesting with the data than display it in the
Output window.
Workflow Example
Having discussed how the Flash Player and the Flash Remoting gateway communi-
cate, now let’s look at what occurs behind the scenes. We will examine each step of
the earlier Hello World example. In Example 1-1, a remote service was called from
Flash and received a “Hello World” string in response.
Here are the steps that occur:
1. Using the NetServices API within Flash, developer-written code makes a call for
a remote service.
2. The NetServices library passes the remote service call, along with any argu-
ments, to the NetConnection object within the Flash Player.
3. The NetConnection object serializes the request into AMF and sends it to server
as an HTTP binary
POST.
4. The Flash Remoting gateway on the server receives the request, deserializes it
and determines the server-side service to which to pass the request.
5. The Flash Remoting gateway on the server invokes the server-side service, pass-
ing any arguments sent along with the request from the Flash Player.
6. The Flash Remoting gateway on the server receives any data returned from the
service (in this case, the string “Hello World”), serializes it into AMF, and
returns it to the client-side Flash Player as an HTTP response.
Kommentare zu diesen Handbüchern