Remoting with AIR

南笙酒味 提交于 2019-12-12 04:23:12

问题


Hi I am trying to set up remoting in an AIR app.

Does anyone know if I need to define a context-root in the compiler settings. Can't seem to find any articles about setting it up, only in flex.

Thanks


回答1:


compiler setting looks like:

-services "X:\tomcat\webapps\blazeds\WEB-INF\flex\services-config.xml"

however, if you want AIR to work over http you have to setup it abit different than a webapp. dunno why, but when using a webapp its enough to setup the flex-server on blazeDS or whatver backend you use and than use something like

protected function createData(event:MouseEvent):void
{

 var javaObject : RemoteObject = new RemoteObject("YOUR_CONFIGURED_JAVA_CLASS");

 javaObject.showBusyCursor = true;

 var token : AsyncToken = javaObject.YOUR_JAVA_METHOD();
 token.addResponder(new mx.rpc.Responder(dataResult,handleFault));

}

but when using AIR you HAVE to setup a destination and endpoint, otherwise it will fail to connect and you will end up with and error like

'Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://ain.swf/blazeds/messagebroker/amf''

so, for AIR apps you have add the following

 javaObject.endpoint = "http://IP:PORT/blazeds/messagebroker/amf";
 javaObject.destination = "hello";

where hello again is the config'd java-class you're calling.

hope that helped.



来源:https://stackoverflow.com/questions/1403806/remoting-with-air

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!