Showing posts with label RemoteObject. Show all posts
Showing posts with label RemoteObject. Show all posts

Is it possible to make httpService Requests synchronous?

RPC communications, including RemoteObject, are asynchronous. In other words, we don’t exactly call a remote method, but rather send a message to the server, requesting a call of the specific Java method. Not only is the client’s request(s) executed asynchronously, but even sending to the server is done asynchronously. And if we need to do multiple RemoteObject invocations in our script, Flex will batch them together and send in the end of the script execution. The results of remote invocations are returned via events. RemoteObject provides the result event for success or fault for failures. We should write the corresponding handler functions. Flex will call these methods, supplying an Event object as a parameter. It’s our responsibility to get the information from the event and act accordingly. Friendly advice: we will save ourself hours of time if we supply a fault handler.

What is the difference between httpService and Data Service?

Basically, Flex allows three types of RPC services: HttpService, WebServices, and RemoteObject Services.
In Flex, using the “RemoteObjects specifies named or unnamed sources and connects to an Action Message Format (AMF) gateway, whereas using the HTTPService and WebService use named services or raw URLs and connect to an HTTP proxy using text-based query parameters or XML”. Specifically, HTTPServices use raw HTTP requests, WebServices use the SOAP protocol and RemoteObjects uses AMF3.
The Flex presentation layer communicates with the business layer by using Flex data services, which are objects we insert in a Flex file. Specifically, we can use Flex data services to interact with the following:
* Web services
* HTTP services
* Remote objects
A Flex data service is an object we insert in an MXML file to communicate with the business layer of a multi-tier application. We use data services to send and receive data from web services, HTTP URLs, and remote objects such as server-based Java objects. An HTTP service is nothing more than an HTTP request to a URL. The primary purpose of HTTP services is to retrieve XML data from an external source.
“RemoteObject provides two advantages over HTTP or SOAP.
First, while the AMF protocol uses HTTP to transfer packets, the data is transferred in a binary format that is natively understood by the Flash Player. As a result, data can move across the network more quickly and it can be deserialized more rapidly than text-based formats such as XML. Both of these result in performance gains, particularly where large sets of data are involved.
Secondly, RemoteObject provides significant productivity advantages. The remoting service, which runs on our server, automatically marshals data between AMF and our server-side language (e.g., PHP, Java, C#). As a result, we can directly call methods on our PHP objects without having to write an XML REST interface or create web service interfaces”.
There are other ways to pass the data from Flex to a server-side Web application. For example, we can create an instance of the URLVariables object, create the data to be passed as its properties,attach URLVariables to URLRequest.data, and call navigateToURL().