一、:1、先打开你的netbeans IDE,选择新建java web的wed application(next)
2、写入你的工程名字并选择路径(next)
3、java ee版本选择java ee5(finish)
4、以上完成后就单击右键(projectname)新建基于模式REST风格的web........,选择简单,单击next把MIME中
改为text/plain.(finish)
二、下载一个(blazeds.rar)解压:
地址:百度一下就OK
把解压后的文件复制到你netbeans工程中的WEB_INF中。修改lib中的remoting-config.xml为:
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service"
class="flex.messaging.services.RemotingService">
<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>com.ws.HelloWorlds</source>
</properties>
</service>
三、再在NetBeans工程中建一个类:HelloWorlds代码如下:
public HelloWorlds(){
}
public String getHelloWorld(String name){
return "Hello "+name;
}
public String validatePassword(String name,String password){
return null;
}
四、接下来就打开FlexBudler:
建立工程代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:RemoteObject id="say" destination="helloWorld">
</mx:RemoteObject>
<mx:Button x="10" y="48" label="click" click="remotingSayHello(event)"/>
<mx:TextInput x="60" y="89" id="tiName"/>
<mx:Label x="10" y="91" text="name:"/>
<mx:Label x="259" y="91" text="{say.getHelloWorld.lastResult}" id="lblView" color="#FCEE09"/>
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
public function remotingSayHello(event:Event):void{
var iname:String=tiName.text;
say.getHelloWorld(iname);
}
]]>
</mx:Script>
</mx:Application>
五、保存并运行,点击click。。。就OK啦。。
注:可能还不够详细,但是是可以看到简单效果的。