Archive

Archive for the ‘Blaze DS’ Category

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