zoukankan      html  css  js  c++  java
  • 跨域访问策略文件在silverlight2 beta2中的变化

    今天将silverlight2 beta1的程序转换成silverlight2 beta2的程序后,发现以前的wcf无法正常调用,vs.net2008 的提示如下:
    "An exception of type 'System.ServiceModel.ProtocolException' occurred in System.ServiceModel.dll but was not handled in user code
    Additional information: The remote server returned an unexpected response: (404) Not Found."
    当直接在网页中输入.svc文件的连接地址的时候发现服务是可用的,于是怀疑是客户端跨域访问策略文件(clientaccesspolicy.xml )产生的问题,查了下资料,原来是在beta2版本中,策略文件的写法有所改变

    Cross-domain restrictions still apply within beta 2 and the same rules apply.  There is one subtle change that is required to your clientaccesspolicy.xml file that is required.  In the allow-from node of the policy file, the attribute http-request-headers is now required.  If your service is an open/public one then specifying “*” is probably acceptable (you’ll have to be the judge of that.  If you only wanted to allow specific headers (besides the blacklisted ones) you can provide those in a comma-separated list and can use wildcards as well.  For example you could use X-MyApp-* if you wanted.

    Another thing to note about the support for Adobe’s crossdomain.xml policy file is one thing we found in interpretation of the policy template.  Previously Flash was a Macromedia product and as such that file is adorned with a DOCTYPE that represents a schema with macromedia in it.  Well, Adobe has changed the schema a little bit and also updated the DOCTYPE to reflect Adobe as the authority.  Right now, Silverlight still expects to validate the macromedia declaration.

    于是将clientaccesspolicy.xml 的内容修改成如下

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


    保存修改,重新编译了一下wcf service,在silverlight 的客户端程序中更新对wcf service的引用,运行成功
  • 相关阅读:
    0309. Best Time to Buy and Sell Stock with Cooldown (M)
    0621. Task Scheduler (M)
    0106. Construct Binary Tree from Inorder and Postorder Traversal (M)
    0258. Add Digits (E)
    0154. Find Minimum in Rotated Sorted Array II (H)
    0797. All Paths From Source to Target (M)
    0260. Single Number III (M)
    0072. Edit Distance (H)
    0103. Binary Tree Zigzag Level Order Traversal (M)
    0312. Burst Balloons (H)
  • 原文地址:https://www.cnblogs.com/alva/p/1217487.html
Copyright © 2011-2022 走看看