Monday, March 31, 2008

AIR & LCDS - How do they work together?

,,,

Its easy to get started with Flex App and LCDS (i assume you know how to).. Use Flex Builder and create a J2EE Project with Remoting enabled. Use the LCDS setup install path for the context root in your dialog and set up the project.

Typically if you make a Flex Application you would ensure that your output directory of the generated SWF lies in the folder location inside the /flex directory or /samples/ directory of your flex application. Relevant config files have to be picked up ... I will describe the configuration files here in brief about LCDS:

-> service-config.xml - Main xml file that includes the below xml files and references them
-> remoting-config.xml - Used for writing destinations of Java/AS mappings using mx:RemotObject
->proxy-config.xml - Used for writing destinations for mx:HTTPServlet/mx:WebService
-> messaging-config.xml - Used to write destinations for mx:MessageProducer, mx:MessageConsumer
->data-management-config.xml - for DataService, fill operations

All these files reside in : C:\lcds\jrun4\servers\default\flex\WEB-INF\flex (On Windows) and /home/username/lcds/jrun4/servers/default/flex/WEB-INF (On Linux) (All this if you are running LCDS 2.5.1)

Using Flex Builder, You can Create an AIR Project with J2EE, LCDS Enabled for the project. So what happens? Your subscription to destinations may not work!! The same stuff on Flex Project works fine. So how do you rectify it?

AIR Projects need some extra settings in-order to work with LCDS -

A) Copy the services-config.xml from the above locatoin on the server to your project 'src' directory.
B) Raneme the copied file as 'custom-services-config.xml'
C) Open the menu in flex builder, Project->Properties
D) Go to the Compiler settings and you will find that the 'services-config.xml' need to be modified to include this one in the new path. i.e., set it as 'custom-services-config.xml'
E) Open the custom-services-config.xml file and look at your default channel (protocol). If you are using 'my-polling-amf' or 'my-rtmp', ensure that you remove the dummy 'http://{server-name}:port' and change it to 'http://localhost:portnumber or http://ip-address:portnumber' (similarly rtmp://{server-name}:port' to rtmp://localhost:portnumber or rtmp://ipaddress:portnumber)
F) Ensure that you have set your Default Channel accordingly as you altered.
G) Also, along with the custom-services-config.xml you would need remoting-config.xml, messaging-config.xml, data-management-config.xml. Copy them all to your local project src directory.
H) Ensure that you write all your destinations two times. One in the local copied files (related config file), and the remotely available config files.

Most problems related to changing of Protocol in LCDS occur due to "NOT CLEANING the Project and re-compiling it". As you change the compiler properties to include custom-services.config.xml, you would have already enabled auto-compile option. So this change will not recompile it unless you make changes to your app. So Ensure that you clean your project and recompile it.

0 comments: