• 跨域访问策略文件在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的引用,运行成功
  • 相关阅读:
    直线DDA,直线和圆的Bresenham算法
    Matlab 多项式及其函数
    Matlab M文件变量检测与传递
    Matlab图形绘制
    C# vb .NET读取识别条形码线性条码ean-8
    C# vb .NET读取识别条形码线性条码code39
    C# vb .NET读取识别条形码线性条码EAN-13
    C# vb .NET读取识别条形码线性条码code128
    C# VB .net读取识别条形码线性条码codabar
    一张图看懂SharpBarcode
  • 原文地址:https://www.cnblogs.com/alva/p/1217487.html
Copyright © 2020-2023  润新知