actionscript-3 - 更改 AMFChannel 中端点的协议(protocol),如何修复?

标签 actionscript-3 apache-flex amf

我正在开发 Flex,我发现当我将 uri(https://jsonplaceholder.typicode.com/posts/1) 提供给 AMFChannel 时,其内容为“HTTPS”协议(protocol),但 Channel 类的calculateEndpoint()方法将协议(protocol)“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>

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

最佳答案

使用 SecureAMFChannel 代替 AMFChannel,如下所示

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

关于actionscript-3 - 更改 AMFChannel 中端点的协议(protocol),如何修复?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42830323/

相关文章:

java - 如何用JAVA解析flash cookies(.SOL文件)

actionscript-3 - 通过代码删除形状

function - 在函数中指定事件类型的优点?,ActionScript 3

Python 解码 AMF 响应

Flex 3 库中的 CSS

apache-flex - 应该使用哪个版本的 flexmojos?

java - Flash发送的未知数据包

apache-flex - FLEX 中的重新调度事件

apache-flex - 服务对象返回

apache-flex - 使用 AIR/Flex 打开本地文件