Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Http托管silverlight应用程序跨域访问https托管服务_Silverlight_Http_Https_Cross Domain - Fatal编程技术网

Http托管silverlight应用程序跨域访问https托管服务

Http托管silverlight应用程序跨域访问https托管服务,silverlight,http,https,cross-domain,Silverlight,Http,Https,Cross Domain,我正在尝试使用web客户端(或webRequest.Create,结果相同)调用rest服务 Silverlight应用程序正在我的机器上开发,url为localhost:13451 Rest服务是使用 获取实体列表的方法的url结构定义如下: 的crossdomain.xml文件可通过访问 并包含以下内容: <?xml version="1.0"?> <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.co

我正在尝试使用web客户端(或webRequest.Create,结果相同)调用rest服务

Silverlight应用程序正在我的机器上开发,url为localhost:13451

Rest服务是使用

获取实体列表的方法的url结构定义如下:

的crossdomain.xml文件可通过访问

并包含以下内容:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
  <allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>


因此,当我尝试发出请求时,Silverlight会抛出一个安全异常,而不会指定错误。有什么办法可以解决这个问题吗?

当您需要向服务添加SL服务引用时,请将其放在您站点的根目录上: clientaccesspolicy.xml

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*"  http-methods="*" >
        <domain uri="http://*"/>
        <domain uri="https://*"/> 
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

和crossdomain.xml,其中包含:

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="SOAPAction">
        <domain uri="*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

并确保可通过浏览器通过http或https访问!
HTH

忽略当前的特定错误,您应该只使用较新的
clientaccesspolicy.xml
文件类型,而不要使用旧的
crossdomain.xml
(仅允许与已经有该文件的旧Flash站点兼容)
clientaccesspolicy.xml
有更多的选项/功能。如果您通过http而不是https访问crossdomain.xml,该怎么办?我也遇到过类似的问题,似乎需要额外的配置才能与https服务通信,而不仅仅是将silverlight指向https URL。您需要在用于连接Silverlight的客户端中使用正确的设置。我还没有找到这个。