- Download and install the software in the Requirements section, and start BEA Workshop Studio.
- Create a new Flex Server project by importing the BlazeDS blazeds.war file (which comes with your download of BlazeDS Beta 1 from Adobe Labs—you can get this from the Requirements section).
- Select File > Import.
- Select the WAR file option. Specify the location of the blazeds.war file that comes with BlazeDS Beta 1. Specify the name of the web project as flex_server.
- Select Finish.
- Select File > Import.
- Create a new Java Class file:
- Right-click Java:Resources: src in the flex_server project.
- Select New > Class. Specify the class Name as HelloWorld.
- Select Finish.
- Add a method to the new HelloWorld.java class:
public String sayHello() { return "hello, World"; }
- Save the file (Control-S or File > Save).
- Configure BlazeDS:
- Open the services-config.xml file, found in the flex_server/WebContent/WEB-INF/flex directory with the Text Editor.
- Update the file to match the following:
<?xml version="1.0" encoding="UTF-8"?> <services-config> <services> <service-include file-path="remoting-config.xml" /> </services> <security> </security> <channels> <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel"> <endpoint uri="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/> </channel-definition> </channels> <logging> <target class="flex.messaging.log.ConsoleTarget" level="Error"> <properties> <prefix>[BlazeDS] </prefix> <includeDate>false</includeDate> <includeTime>false</includeTime> <includeLevel>false</includeLevel> <includeCategory>false</includeCategory> </properties> <filters> <pattern>Endpoint.*</pattern> <pattern>Service.*</pattern> <pattern>Configuration</pattern> </filters> </target> </logging> <system> <redeploy> <enabled>false</enabled> </redeploy> </system> </services-config>
- Save the file.
- Open the remoting-config.xml file, found in the flex_server/WebContent/WEB-INF directory with the Text Editor.
- Update the remoting-config.xml file to match the following code snippet:
<?xml version="1.0" encoding="UTF-8"?> <service id="remoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage"> <adapters> <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/> </adapters> <default-channels> <channel ref="my-amf"/> </default-channels> <destination id="HelloWorld"> <properties> <source>HelloWorld</source> </properties> </destination> </service>
- Save the file.
- Create a new Flex Client Project:
- Select File > New > Project.
- Specify Flex Project.
- Select Next.
- Specify Basic.
- Select Next.
- Specify flex_client as the Project name.
- Specify that the project use the default location.
- Select Next.
- Specify the Output folder to be ${DOCUMENTS}\flex_server\WebContent.
- Select Finish.
- Create the Flex application:
- With the flex_client.mxml application already be open in BEA Workshop Studio, update the file to match the following:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="ro.sayHello()"> <mx:RemoteObject id="ro" destination="HelloWorld"/> <mx:Label text="{ro.sayHello.lastResult}"/> </mx:Application>
- Save the file.
- With the flex_client.mxml application already be open in BEA Workshop Studio, update the file to match the following:
- Update the configuration for the Flex application:
- Right-click flex_client.
- Select Properties.
- Select Flex Compiler.
- Specify two additional compiler arguments (update the path to match the location of your flex_server project):
-services C:\bea\user_projects\workspaces\workshop\flex_server\WebContent\WEB-INF\flex\services-config.xml -context-root /flex_server
- Select OK.
- Create the server that will run the application:
- Select File > New > Other.
- Select Server > Server.
- Select Next.
- Select Apache > Tomcat v5.5.
- Select Next.
- Specify the location where Tomcat is installed and the JRE to use.
- Select Next.
- Select flex_server in the Available projects list.
- Select Add to add the project to the Configured projects list.
- Select Finish.
- Run the application:
- Locate the flex_client.html file in the flex_server/WebContent directory.
- Right-click the flex_client.html file.
- Select Run As > Run on Server.
- Select the Tomcat server.
- Select "Set server as project default."
- Select Finish.
The Flex application runs in the web browser, and displays the string: "Hello, World," which it received from the server through the RemoteObject and BlazeDS.