21 July 2008
Working with remote data using the RPC classes (PDF, 523K)
Up to this point in the book, you have familiarized yourself with the basic methods of Flex: you learned how to use some of the elements that allow you to define the user interface of an application, how to load external data using data models, and how to convert these data models into collection classes.
The next logical topic for discussion is remote data sources. Flex takes care of the presentation part of the application, but it does not have native access to any databases. Remote data sources allow you to take advantage of the RPC classes to perform calls to business logic built using ColdFusion, Java, or any other server-side technology to send and receive remote data. RPC, which stands for remote procedure call, allows you to execute a subroutine or procedure either locally or on another computer without having to code specific procedures for the remote interaction. For more details on RPC, check out the Wikipedia article on remote procedure call.
In Flex, the RPC services provide a call-and-response model to access remote data and expose the components based on service-oriented architecture (SOA). There are three RPC classes in Flex: the HTTPService class, the WebService class (compliant with Simple Object Access Protocol, or SOAP), and the RemoteObject class.
Figure 1. The HTTP call is executed on the creationComplete event of the application.