Flex Spring BlazeDS Integration (on public web server)

This won’t be a post about how to integrate Flex and Spring. Actually I intended to be one, but several days ago James Ward posted this tutorial on how easy it is to do with Flash Builder 4 so I thought it won’t be necessary.

Edit:  you can checkout the new post of how to upload files with Flex and Spring

What I will show is how to upload our project to a free Java and Tomcat host to test it, connect our Flex application to it and show this example here. I’ve been looking for such free hosting and the only thing I’ve found (if there are any others please comment) is eatj.com that provides a free trial limited up to 50 MBs of storage and every 6 hours the server is restarted, but for testing is fine.

I assume that you already created your Spring project based on the tutorial. I’ve added small changes for the current example, if you want the source of the example get it from here. Now right click on the project -> Export -> WAR file and select where to export it.
Now we log into our account in eatj.com and upload the war file, restart the server and this is it.

Now for the Flex part, although I haven’t used the Data Wizards from Flash Builder (as I’ve had small problems) I did it the old fashioned way and the source is:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768"
         applicationComplete="remoteObject.addMessage(null, null, null)">
  
    <![CDATA[
      import mx.controls.Alert;
    ]]>
  
  
    
      
        
          
        
      
    
  
  
  
    
      
      
      
    
  
  
    
    
      
    
    
      
    
    
  


Yep that is Flex 4, my first Flex 4 app in my blog 🙂

So now we compile it and we have our swf. For this example I will upload it to http://sites.google.com/ which I use to publish my files to.
There is one last thing to do, to create and configure a crossdomain.xml on our server.

We create on out local machine crossdomain.xml looking like:

<!DOCTYPE cross-domain-policy 
  SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">

   

The weakness here is that everyone from *.googlegroups.com can connect, but as this is an example it is not a problem, and I don’t think someone will be that interested 🙂

Now with your favorite ftp client, connect it to host: s215.eatj.com port:21 your account’s username and password. Navigate to /webapps/ROOT and copy the crossdomain.xml there.

Click here to see the result. EDIT: Unfortunately the eatj trial account shuts down the server 6 hours after it was started. That’s why sometimes you wont be able to connect to the server

Source code:
spring-flex-server
FlexSpring

Advertisements

2 comments

  1. autor · April 15, 2010

    Thank you ! this article saved me a lot of time today 🙂

    Good luck.

    Like

  2. aparna john · October 4, 2013

    Hi,Any website with a great amount of content and user data needs a cms. Content Management System allows website owners in Web Design Cochin maintain website data and all types of content. Plus, a good CMS can help to improve website overall functioning.Thanks………..

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s