18.12.使用SecureAMFChannel进行AMF的安全通信

18.12.1. 问题
我需要使用AMF 数据和安全Sockets 层(SSL)通过Flash Remoting 进行通信。
18.12.2. 解决办法
在编译程序所使用的services-config.xml 文件中定义你的channel 为SecureAMFChannel。
18.12.3. 讨论
SecureAMFChannel 可让你使用基于SSL 的AMFChannel 通信,以确保通过AMFChannel 发送的数据都是安全的。要创建一新的channel,使用安全版本的AMF 类,只要在servicesconfig.

xml 文件的channel 中使用mx.messaging.channels.SecureAMFChannel 作为其类,终端(endpoint)设置为flex.messaging.endpoints.SecureAMFEndpoint 类:
+展开
-XML
<channels>
<channel ref="secure-amf"/> 
</channels>
<channel-definition id="secure-amfclass="mx.messaging.channels.SecureAMFChannel">
<endpoint uri="https://{server.name}:{server.port}/gateway/"
class="flex.messaging.endpoints.SecureAMFEndpoint"/>

<properties>
<add-no-cache-headers>false</add-no-cache-headers>
<polling-enabled>false</polling-enabled>
<serialization>
<instantiate-types>false</instantiate-types>
</serialization>
</properties>
</channel-definition>

上面的代码可用于ColdFusion, Adobe LiveCycle, 和BlazeDS:
+展开
-XML
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxmlwidth="400height="300creationComplete="init()">
<mx:RemoteObject id="channelRO"/>
<mx:Script>
<![CDATA[
import mx.messaging.ChannelSet;
import mx.messaging.channels.SecureAMFChannel;
private var cs:ChannelSet
private function init():void {
cs = new ChannelSet();
// note that the name of the channel is the same as
in the services-config.xml file
var chan: SecureAMFChannel = new SecureAMFChannel("secure-amf","gateway")
chan.pollingEnabled = true;
chan.pollingInterval = 3000;
cs.addChannel(chan);
channelRO.channelSet = cs;
}

]]>
</mx:Script>
</mx:Application>

现在你可以使用此channel 调用RemoteObject 和建立安全的AMF 轮询调用。

加支付宝好友偷能量挖...


评论(0)网络
阅读(194)喜欢(0)flash/flex/fcs/AIR