【问题标题】:Flex crossdomain.xml not working correctly in Chrome/Firefox?Flex crossdomain.xml 在 Chrome/Firefox 中无法正常工作?
【发布时间】:2026-02-13 19:20:03
【问题描述】:

我在这方面花了很多时间,所以这就是我卡住的地方。

我正在使用调试播放器 10.1 从以下位置获取 XMLA 请求:

http://localhost/dir/blah.swf

到:

http://localhost/olapbin/msblah.dll

这在文件系统中运行良好,但现在它在 IIS7 Web 服务器上。

经过大量摆弄 crossdomain.xml 文件后,我决定:

<?xml version="1.0"?>
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-access-from domain="*" to-ports="*" />
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

放置在:

http://localhost/crossdomain.xml

并阅读:

Security.loadPolicyFile("http://localhost:80/crossdomain.xml");

我设置了策略文件日志记录(这有助于提出上述文件) 在 IE8 上它一切正常。我明白了:

OK: Root-level SWF loaded: http://127.0.0.1/akts/ThinSlicerRunner.swf
OK: Policy file accepted: http://localhost/crossdomain.xml
OK: Searching for <allow-access-from> in policy files to authorize data loading from resource at http://localhost/olapbin/msmdpump.dll by requestor from http://127.0.0.1/akts/ThinSlicerRunner.swf
OK: Searching for <allow-http-request-headers-from> in policy files to authorize header sending to URL http://localhost/olapbin/msmdpump.dll by requestor from http://127.0.0.1/akts/ThinSlicerRunner.swf
OK: Request for resource at http://localhost/olapbin/msmdpump.dll by requestor from http://127.0.0.1/akts/ThinSlicerRunner.swf is permitted due to policy file at http://localhost/crossdomain.xml

在 Chrome 和 Firefox 上我刚刚得到:

OK: Root-level SWF loaded: http://localhost/akts/ThinSlicerRunner.swf
OK: Policy file accepted: http://localhost/crossdomain.xml

除此之外……没有尝试授权 httpservice 请求。

在主 flex 错误日志中我得到:

*** Security Sandbox Violation ***
Connection to  
http://localhost/olapbin/msmdpump.dll
  halted - not permitted from http://localhost/akts/ThinSlicerRunner.swf

当我从 IE8 运行相同的东西时,它不会出现。 知道发生了什么吗??

根据要求...更多代码

主要发送请求:

var connection:TsConnection = this.__connection; 
var token:AsyncToken = new AsyncToken(null);
connection.service.request = this.__curSoapRequest;  
var actualToken:AsyncToken = connection.service.send();
__tokenArr.push(actualToken);
var responder:AsyncResponder = new AsyncResponder(resultHandler, faultHandler, actualToken);
__responderArr.push(responder);
actualToken.addResponder(responder);

连接对象亮点:

   public function init():void {

        //Initialize the service object needed to query the server

    this.__service = new HTTPService;
    this.__service.method = "POST";
    this.__service.contentType = "application/xml";
    this.__service.resultFormat = "e4x";
    this.__service.headers = getHeaders();
    this.__service.url = this.__model.xmlaUrl;
    this.__initialized = true;
}

public function get service():HTTPService {
    return this.__service;
}

private function getHeaders():Object {
    var o:Object = {};
    o["SOAPAction"] = '"urn:schemas-microsoft-com:xml-analysis:Discover"';
    o["Content-Type"] = "text/xml";
    return o;
}   

感谢您的帮助...希望修复后对其他人有所帮助。 ;-)

肖恩 http://www.vidgridz.com/

【问题讨论】:

    标签: apache-flex flash google-chrome policy crossdomain.xml


    【解决方案1】:

    感谢大家的回答。确实可以在代码中解决 即使这不是一个真正的编码问题。

    这是我从中读取配置详细信息的 xml 数据文件:

    <tsConnection>
    <dataSource>megan</dataSource>
    <database>Adventure Works DW 2008</database>                
    <cube>Adventure Works</cube>
    <xmlaUrl><![CDATA[ 
    http://localhost/olapbin/msmdpump.dll
     ]]></xmlaUrl>
    </tsConnection>
    

    现在在“localTrusted”或“localWithNetworking”设置上,这工作得很好。 即使在“远程”下,它也可以在 IE8 Flash 播放器上运行。

    但是,发生的事情是 xmlaUrl 被读取为:

    \n\rhttp://localhost/olapbin/msmdpump.dll
    

    (以换行符和回车符开头) 这就是混淆域检查并引发沙盒违规的原因 在“远程”安全沙箱中运行时。

    当然,我的 xml 应该会更好,可能会放一些忽略白 代码中的空间处理,但仍然相当奇怪,不一致 Netscape 兼容浏览器 (10.1.x) 中 Flash 播放器代码的行为。

    所以最终的可行解决方案如下所示:

    <tsConnection>
    <dataSource>megan</dataSource>
    <database>Adventure Works DW 2008</database>                
    <cube>Adventure Works</cube>
    <xmlaUrl><![CDATA[http://localhost/olapbin/msmdpump.dll]]></xmlaUrl>
    </tsConnection>
    

    不过,我确实在此过程中成为了 crossdomain.xml 专家。 ;-) 虽然,现在我根本不需要这个文件。

    请记住,如果您看到一些疯狂的、无法解释的沙盒违规行为,请检查 服务网址中的空白。

    【讨论】:

      【解决方案2】:

      如果您的 DLL 后端服务和 SWF 来自同一个域,则应该允许。 crossdomain.xml 文件中的任何内容都不应适用。您也不必手动加载跨域文件。听起来这就是你想要做的。

      我怀疑你的代码有其他问题。

      【讨论】:

      • 我很欣赏它不需要 crossdomain.xml 文件。我也明白它不应该手动加载。然而,这至少让 IE 中的一些东西让我感觉更好。不管发生了什么,对我来说,这似乎是无证的、不受欢迎的魔法;-) 我附加了更多代码。接下来要尝试的是标准(非调试)Flash 播放器,然后是旧版本。
      • 您在使用 Flex 吗?如果是这样,您为什么不使用 WebService 标记?看来你的事情很艰难。