Home > ActionScript 3, Blaze DS, Flash Platform > BlazeDS: Worth figuring out! HelloWorld Example

BlazeDS: Worth figuring out! HelloWorld Example

March 2nd, 2008

I am working on a project for John Deere and they have a huge WebSphere implementation. The odds of transferring them over to AMFPHP are not very realistic! Anyways, I spent the weekend playing with BlazeDS as my endpoint for Flex and I really like it. I took me about six hours to figure out tomcat, java in eclipse, and the whole server side endpoint thing. From there it has only taken me about an hour to figure out class mapping, authentication, push technology, and connecting everything to hybernate. So to anyone looking into using BlazeDS stick with it a bit. The biggest hurdle is probably java and tomcat for those like me that don’t understand why you need to restart the application server sometimes and other times it just works. Overall great job Adobe and thanks for releasing a quality opensource project.

The following is my simple hello world example that I used to get started with learning how this system works.

Here are all the files Zipped. I can not figure out how to do code highlighting. Suggestions~!

helloworld-blazeds.zip

Java Class File for remote service. Place compiled class in $tomcat_home/webapps/blazeds/WEB-INF/classes/HelloWorld.class

import java.util.Date;
public class HelloWorld {
	private String userSaid;
	public String repeat(String said) {
		this.userSaid = "Reply from server: " + said;
		return this.userSaid;
	}
	public String sayHello() {
		Date now = new Date();
		return "Hello World " + now;
	}
}

Remoting-config.xml place in $tomcat_home/webapps/blazeds/WEB-INF/flex/remoting-config.xml


    
        
    
    

   			HelloWorld
   		
   
    
        
    

services-config.xml $tomcat_home/webapps/blazeds/WEB-INF/flex/services-config.xml


	
		
			
	        	
	    	
	    	

	            	HelloWorld
		        
		        
					
				
	    	
    	
	
	
		
			
		
	

That’s it for the server side. Now you just need two files updated to run this from Flex.



    
        
        
    

    
        
    

    
    
    
    
    

And then your services-config.xml file in your flex project. Note that this can be the same file as what is on the server! But it needs to be in both places.



    class="flex.messaging.services.RemotingService">

    
        
    
    

   			HelloWorld
   		
   
    
        
    


That’s it! Now you have your first class connecting against BlazeDS!

ActionScript 3, Blaze DS, Flash Platform

  1. Mario
    March 4th, 2008 at 05:42 | #1

    Great, thx! It works. When downloading the Zip take care to adjust your endpoint uri. :)

  2. Nat
    June 23rd, 2008 at 17:41 | #2

    I greatly appreciate the example, however, being completely new to Flex and BlazeDS, I’m not sure how to adjust the uri endpoint correctly. There’s no messagebroker location on my tomcat server (???). Apologies for the novice question.

  3. October 14th, 2008 at 07:39 | #3

    Hey Wade,

    Thanks for this mini tutorial. I am looking fotwatd to work with blazeDS and this post of yours is a good boost to start with. :)

  4. December 16th, 2008 at 17:39 | #4

    [FaultEvent fault=[RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://localhost:8080/mms/messagebroker/amf'"] messageId=”F00306EE-8E93-05EE-5E13-41F39B10DC7B” type=”fault” bubbles=false cancelable=true eventPhase=2]

    Why mms in http://localhost:8080/mms/messagebroker/amf?

  5. Stevie
    March 17th, 2009 at 22:08 | #5

    Hi there,

    Is there the possibility/chance to get a FLEX / BlazeDS / AMFPHP – solution? This would be a great offer for all non-java, php/flex/as3 coders…to reach the world of realtime collabrations etc..

    Meanwhile is there a resource to learn the good old stuff, like the insert/update/select mysql in conjunction with a Flex/BlazeDS environment again/new in Java?

    Well, actually my dream is to do this realtime stuff as FLEX / BlazeDS / AMFPHP – solution using my PHP/AS3 skills.

  6. Joel
    April 14th, 2009 at 09:52 | #6

    Stevie :
    Hi there,
    Is there the possibility/chance to get a FLEX / BlazeDS / AMFPHP – solution? This would be a great offer for all non-java, php/flex/as3 coders…to reach the world of realtime collabrations etc..
    Meanwhile is there a resource to learn the good old stuff, like the insert/update/select mysql in conjunction with a Flex/BlazeDS environment again/new in Java?
    Well, actually my dream is to do this realtime stuff as FLEX / BlazeDS / AMFPHP – solution using my PHP/AS3 skills.

    AMFPHP is an AMF solution. BlazeDS is an AMF solution. While not completely mutually exclusive, they really are mutually exclusive. Either or.

    @wade There really isn’t any reason to put your destination in both services and remoting if you use the default config files. The remoting-config is an include of services-config. Keep it DRY and whatnot.

  7. Rupali
    May 7th, 2009 at 01:53 | #7

    Have you tried creating new Flex application which will use BlazeDS and will be hosted on IBM WAS? Any suggestions/comments will be helpful.

  8. June 22nd, 2009 at 08:42 | #8

    @Xevi Colomer
    Hey i tried the following endpoint as i configured blazeDS on 8400 port

    http://localhost:8400/blazeds/messagebroker/amf

    and that worked perfectly.

  9. August 10th, 2009 at 12:24 | #9

    Nice hello world Example, just the kind I’ve been looking for. Thanks for sharing.

  10. October 20th, 2009 at 05:51 | #10

    If you want to read other blazeDS base example go to http://programmaremobile.blogspot.com/2009/10/java-and-blazeds-by-example.html

  11. KenTseng
    October 29th, 2009 at 21:58 | #11

    Great share, thanks a lot!!

  12. Varun Bajaj
    July 10th, 2010 at 17:48 | #12

    Hi, This is really nice hello world example. Earlier worked with PHP and looking for example to communicate flex with java, This example help me a lot. Thanks for sharing.

  1. July 31st, 2009 at 15:44 | #1