更改AMFChannel中的端点协议,如何解决?

时间:2017-03-16 09:43:01

标签: actionscript-3 flex amf

我正在使用Flex,我发现当我将uri( https ://jsonplaceholder.typicode.com/posts/1)提供给AMFChannel时,内容为'HTTPS'protocal但 calculateEndpoint() Channel类的方法将协议“HTTPS”更改为“HTTP”

我还制作了一个简单的项目来演示如何通过AMFChannel更改端点。

<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script><![CDATA[
    import mx.controls.Alert;
    import mx.messaging.ChannelSet;
    import mx.messaging.channels.AMFChannel;
    import mx.rpc.AbstractOperation;
    import mx.rpc.remoting.mxml.RemoteObject;


    private function button1_clickHandler(event:MouseEvent):void
    {
        var amfChannelWeb:AMFChannel = new AMFChannel("amfChannel", txtInput.text);

        var remoteObj:RemoteObject = new RemoteObject();
        remoteObj.showBusyCursor = true;
        remoteObj.requestTimeout = 0;

        var channelSet = new ChannelSet();
        channelSet.channels = [amfChannelWeb];


        remoteObj.destination = "amfphp";
        remoteObj.channelSet = channelSet;


        var op:AbstractOperation = remoteObj.getOperation("testAmfData");
        op.send();
        op.addEventListener("result", resultHandler);
        op.addEventListener("fault", resultFaultHandler);
        lblEndpoint.text = amfChannelWeb.endpoint;
    }

    private function resultHandler(e:Event):void
    {
        lblChannelError.text = e.toString();
    }

    private function resultFaultHandler(e:Event):void
    {
        lblChannelError.text = e.toString();
    }
    ]]></fx:Script>

<s:VGroup width="100%">

    <s:TextInput width="80%" id="txtInput" text="https://jsonplaceholder.typicode.com/posts/1"/>
    <s:Button click="button1_clickHandler(event)" label="Click"/>
    <s:Label id="lblEndpoint"/>
    <s:Label id="lblChannelError"/>

</s:VGroup>

这个问题还是我做错了什么?

1 个答案:

答案 0 :(得分:3)

而不是AMFChannel使用SecureAMFChannel如下

 var amfChannelWeb:SecureAMFChannel = new SecureAMFChannel("amfChannel", txtInput.text);