1. 新增web 项目 :FirstBlazeDSServer
2. 在tomcat的webapps文件夹下,新建一个FirstBlazeDSServer文件夹
3. 加压blazeds.war 至FirstBlazeDSServer夹
4. 拷贝所有 WEB-INF文件夹到 FirstBlazeDSServer项目的WebContent,提示是否覆盖 yes to all
5.修改编译路径
6.同步编译文件到tomcat的webapps/FirstBlazeDSServer/WEB-INF
7. 新建一个test.HelloWord
package test; public class HelloWord { public String sayHello(String name){ return "Hello !" + name; } }8. 修改 WebContent/WEN-INF/flex/remote-config.xml
<destination id="hello"> <properties> <source>test.HelloWord</source> </properties> </destination>9.添加项目到tomcat,并启动tomcat
9.创建一个Flex项目:FirstBlazeDSClient
单击 Validate Configuration 按钮 ,验证通过,单击Finish完成Flex项目的创建。
10.修改FirstBlazeDSClient.xml文件
<?xml version="1.0" encoding="utf-8"?> <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/mx" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)"> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <fx:Script> <![CDATA[ import mx.controls.Alert; import mx.events.FlexEvent; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; protected function ro_resultHandler(event:ResultEvent):void { Alert.show(event.result as String); } protected function ro_faultHandler(event:FaultEvent):void { Alert.show(event.fault.faultString); } protected function application1_creationCompleteHandler(event:FlexEvent):void { ro.sayHello("ddd"); } ]]> </fx:Script> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> <s:RemoteObject id="ro" result="ro_resultHandler(event)" fault="ro_faultHandler(event)" destination="hello" endpoint="http://localhost:8686/FirstBlazeDSServer/messagebroker/amf"/> </fx:Declarations> </s:Application>
成功配置BlazeDS框架