最近在搞flex,采用blazeDS 的rpc来访问java后台,而且是即时编译形式的。这里总计一下remoteObject的用法:
1,如果跨域访问,就必须指定:endpoint或channelSet:示例如下
2,或者采用 operation,这样可以指定调用的方法名。
3,还有就是关于访问策略文件,总报错,正在调查中,不过不影响访问。
请求的URL地址:
调用后成功的界面截图:
[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]
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]