Flex BlazeDS+Spring RemoteObject使用案例

最近在搞flex,采用blazeDS 的rpc来访问java后台,而且是即时编译形式的。这里总计一下remoteObject的用法:
1,如果跨域访问,就必须指定:endpoint或channelSet:示例如下
	<mx:RemoteObject id="ro"  destination="commonService"  result="showRes(event);" fault="showErr(event);">
</mx:RemoteObject>


var cs:ChannelSet = new ChannelSet();
cs.addChannel(new AMFChannel("myAMF","http://localhost:8080/FLX/messagebroker/amf"));
//ro.channelSet = cs;//ok
ro.endpoint="http://localhost:8080/FLX/messagebroker/amf";//ok
//以上2个只要指定一个就可以
ro.doService("{pass:1,a:'abc'}","json");


2,或者采用 operation,这样可以指定调用的方法名。


var cs:ChannelSet = new ChannelSet();
cs.addChannel(new AMFChannel("myAMF","http://localhost:8080/FLX/messagebroker/amf"));
//ro.channelSet = cs;//ok
//ro.endpoint="http://localhost:8080/FLX/messagebroker/amf";//ok
//ro.doService("{pass:1,a:'abc'}","json");
ro.showBusyCursor=true;
var op:Operation = ro.getOperation("doService") as Operation;
op.service.channelSet = cs;//这里指定channel,否则跨域访问报错
op.send(para,"json");


3,还有就是关于访问策略文件,总报错,正在调查中,不过不影响访问。
Security.loadPolicyFile("http://localhost:8080/FLX/crossdomain.xml");

请求的URL地址:

http://localhost:8080/FLX/app/flex/Test_RO.mxml?debug=true

调用后成功的界面截图:
[img]http://keren.iteye.com/upload/attachment/99110/7cca61c1-3da0-3f51-b3bc-5631e45343ff.jpg[/img]
调用后成功的web控制台信息:
[img]http://keren.iteye.com/upload/attachment/99630/5da71731-fd91-341f-9cf8-59c6cecdd31a.jpg[/img]

========================================================
[flex 与远程调用中间转换过程 概念]
[url]http://newtamato.iteye.com/blog/359779[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值