Working with BlazeDS Remote Data Services using Flex 4.0

Working with BlazeDS Remote Data Services using Flex 4.0

What is BlazeDS?

BlazeDS is a collection of data services that help and simplify building of data driven RIA. They also improve the performance of remote data access operations. BlazeDS supports and enables real time data push and asynchronous collaborative applications. BlazeDS service is deployed on Java EE web/application server.

also read:

The Flex components like Remote Object, Producer, Consumer, HTTPService and WebService interact with a BlazeDS server.

BlazeDS supports with three varieties of key services:

  • The Remoting Service: This enables Flex application to directly interact and invoke methods of remote Java objects that are deployed in application server.
  • The Message Service: This supports and enables Flex application to interact with publish/subscribe mechanism to publish and subscribe messages to a messaging destination. This enhances the building of application with real time data push and collaboration.
  • The Proxy Service: This enables Flex application to implement secure and reliable using cross domain service requests. Flex applications can access services from different domains.

BlazeDS looks after instantiating and managing the remote objects’ life cycle configured in remoting-config.xml.

Working with Remote Objects using BlazeDS

  • Step 1: BlazeDS environment setupThe BlazeDS server can be downloaded from the Adobe open source. It works with Tomcat to deploy its services.
  • Step 2: Create a Java Web project FlexWebAppUpdate the web.xml with the following:

    configuring web.xml

     <!-- Http Flex Session by binding listener support -->
    	<!-- Servlet : MessageBroker -->
    		<!-- loading the services-config.xml -->
  • Step 3: Copy and paste the required jars from BlazeDS turnkey server to WEB-INF/lib folder
  • Step 4: Create a folder called flex and place the xml files like messaging-config, proxy-config, remoting-config and services-config inside downloaded from BlazeDS server.The services-config.xml includes and loads the above mentioned xml files.
  • Step 5: Update the remoting-config.xml with following entry:
     <!—creating the destination for the StockQuoteService remote Java object
    	<destination id="stockQuote">
  • Step 6: Create the Flex client application as below:
     <?xml version="1.0" encoding="utf-8"?>
    	<s:Application xmlns:fx="" 
    		xmlns:mx="library://" minWidth="955" minHeight="600">
    		<!-- declaring the remote object in the declaration to connect to BlazeDS destination -->
    			<s:RemoteObject id="myStock" destination="stockQuote"/>
    		<s:Panel title="Stock Quotes" width="600" height="240"
    			verticalCenter="0" backgroundColor="#7DE4D9" contentBackgroundColor="#BEBB5D" chromeColor="#6CB6B3" rollOverColor="#7792BC">
    			<!-- connecting the data provider of data grid to the remote onject -->
    			<mx:DataGrid width="100%" dataProvider="{myStock.getStocks.lastResult}" />
    			<!-- invoking the method of the remote object -->
    			<s:Button  label="Get Stocks" click="myStock.getStocks()"/>

Creating server side Java object

  • Step 7: Create the Java application and deploy to the BlazeDS web application
     package mypack;
    	import java.util.HashMap;
    	public class StockQuoteService {
    		HashMap stocks[]=new HashMap[5];
    		public StockQuoteService()
    			for(int i=0;i<5;i++){
    				stocks[i]=new HashMap();
    		public HashMap[] getStocks()
    			return stocks;

    The .class of above Java class must be placed in the classes/mypack folder.

  • Step 8: The J2EE BlazeDS server details need to be configured either when the Flex application is created or update in the Flex server details of flex application as follows:

  • Step 9: Restart tomcat
  • Step 10 : run the flex applicationThe data grid incorporates the receiving result from the remote object and prepares the grid accordingly.


The BlazeDS server consists of a Java EE web application. A Flex client sends a request thru a channel then the request is directed tiwards to an endpoint/post on the BlazeDS server. Then the request is further routed thru a chain of Java objects including the MessageBroker , a service, a destination, and adapter objects. The adapter checks to get the request served locally or remote server.

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Share This

Share this post with your friends!