本人使用flash builder4、eclipse、blazeds 4进行测试。
配置步骤:
1.在Eclipse中创建一个动态Web项目
2.解压BlazeDs中的blazeds.war,有META-INF、WEB-INF文件夹,将其拷贝到刚刚我们创建的项目中替换已有的文件。
3.编写测试类
package com.blazeds;
public class HelloWorld {
public String sayHello(){
return "Hello BlazeDs";
}
}
4. 配置WEB-INF\flex\remoting-config.xml文件,添加如下内容:
<destination id="helloWorld">
<properties>
<source>com.blazeds.HelloWorld</source>
</properties>
</destination>
5.启动tomcat服务器
6.在flash builder中创建一个基于Web的工程test
7.配置工程属性
8.在flash builder中编写测试代码
<?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" preloaderChromeColor="#B55A5A">
<fx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
private function successHandler(event:ResultEvent):void {
Alert.show(event.result.toString(), "成功");
}
private function failureHandler(event:FaultEvent):void {
Alert.show(event.fault.toString(), "失败");
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<mx:RemoteObject id="remoteObject" destination="helloWorld" result="successHandler(event)" fault="failureHandler(event)"/>
</fx:Declarations>
<mx:Button label="Hello" click="remoteObject.sayHello()" x="196.5" y="98"/>
</s:Application>