1. Download and install the software in the Requirements section, and start BEA Workshop Studio.
  2. 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).
    1. Select File > Import.

      Importing the blazeds.war file

      Figure 1. Importing the blazeds.war file

    2. 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.

      Naming the web project

      Figure 2. Naming the web project

    3. Select Finish.
  3. Create a new Java Class file:
    1. Right-click Java:Resources: src in the flex_server project.
    2. Select New > Class.  Specify the class Name as HelloWorld.

      Creating a new class

      Figure 3a. Creating a new class

      Naming the new class HelloWorld

      Figure 3b. Naming the new class HelloWorld

    3. Select Finish.
    4. Add a method to the new HelloWorld.java class:
      public String sayHello() 
      { 
      return "hello, World"; 
      }
    5. Save the file (Control-S or File > Save).
  4. Configure BlazeDS:
    1. Open the services-config.xml file, found in the flex_server/WebContent/WEB-INF/flex directory with the Text Editor.
    2. 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>
    3. Save the file.
    4. Open the remoting-config.xml file, found in the flex_server/WebContent/WEB-INF directory with the Text Editor.

      Opening remoting-config.xml with the Text Editor

      Figure 4. Opening remoting-config.xml with the Text Editor

    5. 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>
    6. Save the file.
  5. Create a new Flex Client Project:
    1. Select File > New > Project.
    2. Specify Flex Project.

      Creating a new Flex project

      Figure 5. Creating a new Flex project

    3. Select Next.
    4. Specify Basic.

      Specifying the way you want to access data in your application

      Figure 6. Specifying the way you want to access data in your application

    5. Select Next.
    6. Specify flex_client as the Project name.

      Naming the project

      Figure 7. Naming the project

    7. Specify that the project use the default location.
    8. Select Next.
    9. Specify the Output folder to be ${DOCUMENTS}\flex_server\WebContent.
    10. Select Finish.
  6. Create the Flex application:
    1. 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>
    2. Save the file.
  7. Update the configuration for the Flex application:
    1. Right-click flex_client.
    2. Select Properties.
    3. Select Flex Compiler.
    4. 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
    5. Select OK.
  8. Create the server that will run the application:
    1. Select File > New > Other.
    2. Select Server > Server.
    3. Select Next.
    4. Select Apache > Tomcat v5.5.



      Figure 8. Selecting the server that will run the application

    5. Select Next.
    6. Specify the location where Tomcat is installed and the JRE to use.

      Specifying the location for the Tomcat server

      Figure 9. Specifying the location for the Tomcat server

    7. Select Next.
    8. Select flex_server in the Available projects list.
    9. Select Add to add the project to the Configured projects list.

      Adding the project to the Configured projects list.

      Figure 10. Adding the project to the Configured projects list.

    10. Select Finish.
  9. Run the application:
    1. Locate the flex_client.html file in the flex_server/WebContent directory.
    2. Right-click the flex_client.html file.
    3. Select Run As  > Run on Server.
    4. Select the Tomcat server.

      Running the application on the Tomcat server

      Figure 11. Running the application on the Tomcat server

    5. Select "Set server as project default."
    6. 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.

posted on 2009-09-20 23:17  sky100  阅读(845)  评论(0编辑  收藏  举报