flex通过BlazeDS与java后台通信
2015-01-08 16:18
267 查看
1.通过WTP创建BlazeDS的Flex项目,可参考
http://note.youdao.com/share/?id=8455692f104b5610131f8befe9f4c681&type=note
2.添加后台service类,如下
3.修改remoting-config.xml文件中添加以下代码
4.前台Flex调用方法
5.如果出现错误如下图:
导致原因是url不对。解决:修改.flexProperties文件中的,serverContextRoot为项目的名称。
6.若出现以下界面,则说明调用成功。
http://note.youdao.com/share/?id=8455692f104b5610131f8befe9f4c681&type=note
2.添加后台service类,如下
package com.service; public class Test { public String testFlex(String ars){ return "Hello "+ars; } }
3.修改remoting-config.xml文件中添加以下代码
<destination id="myTest"> <properties> <source>com.service.Test</source> </properties> </destination>
4.前台Flex调用方法
<?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"> <fx:Script> <![CDATA[ import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.rpc.remoting.RemoteObject; protected function button1_clickHandler(event:MouseEvent):void { var remoObj:RemoteObject=new RemoteObject(); remoObj.destination="myTest"; remoObj.testFlex("suxiaoyong"); remoObj.addEventListener(FaultEvent.FAULT,fieldFunction); remoObj.addEventListener(ResultEvent.RESULT,resultFunction); remoObj.showBusyCursor=true; } //调用失败后返回 private function fieldFunction(e:FaultEvent):void{ Alert.show("调用失败"+e.fault.toString()); } //调用成功后返回 private function resultFunction(e:ResultEvent):void{ var result:String=e.result.toString() Alert.show(result); } ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <s:Button label="点击" click="button1_clickHandler(event)"/> </s:Application>
5.如果出现错误如下图:
导致原因是url不对。解决:修改.flexProperties文件中的,serverContextRoot为项目的名称。
6.若出现以下界面,则说明调用成功。
相关文章推荐
- 通过blazeds让FLEX与java通信
- Flex 与java 通信,通过BlazeDS
- 通过blazeds让FLEX与java通信
- Flex与java通过BlazeDS实现通信(简单Demo)
- Flex通过Blazeds利用Remoteservice与后台java消息推送
- 通过blazeds让FLEX与java通信
- Flex通过Blazeds利用Remoteservice与后台java消息推送
- Flex与java 通过BlazeDS实现通信(简单Demo)
- Flex与java通过BlazeDS实现通信(简单Demo)
- Flex与java通过BlazeDS实现通信(简单Demo)
- Flex通过Blazeds利用Remoteservice与后台java消息推送
- flex+blazeds+java+spring后台消息推送,有界面维护
- 使用BlazeDS实现Java和Flex通信。
- Flex4 + Blazeds + Java 通信
- Flex同Java通信--BlazeDS入门图文详解(上)
- FLEX 与 Java 通信 使用blazeds架构
- flex+blazeds+java后台消息推送(简单示例)
- 使用BlazeDS实现Java和Flex通信。
- 使用BlazeDS实现java与flex传对象时,RemoteClass中包含自己写的类,后台无法转换的问题
- flex和java基于blazeds的通信(转)