Silverlight转WCF跨域异常,但clientaccesspolicy.xml读取成功

发布于 2024-11-27 02:44:38 字数 1468 浏览 0 评论 0原文

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>

crossdomain.xml

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy>
<cross-domain-policy>
  <allow-http-request-headers-from domain="*" headers="*" secure="true" />
</cross-domain-policy>

这里没什么花哨的,它是数百万 WCF 服务用来允许 Silverlight 客户端访问它们的标准设置。不幸的是,这个设置在我部署的实时环境中不起作用。用于测试部署的预生产环境的设置与实际环境相同(或者系统管理员声称),并且一切都在那里完美运行,这就是我如此困惑的原因。

我让一位系统管理员使用 HTTPDebuggerPro 跟踪来自 Silverlight 客户端的请求,它显示客户端正在毫无问题地检索 clientaccesspolicy.xmlcrossdomain.xml(HTTP状态 200)。但是,请求这些文件后,客户端尝试调用服务并立即收到 CrossDomainException

我还尝试让系统管理员将 WCF 服务 URL 添加到托管 Silverlight 客户端的 Internet Explorer 的“允许的站点”列表中(根据 http://blogs.msdn.com/b/fiddler/archive/2010/11/22/fiddler-and-silverlight-cross-zone-cross-domain-requests.aspx)但这也不起作用。

哈尔普!

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>

crossdomain.xml:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy>
<cross-domain-policy>
  <allow-http-request-headers-from domain="*" headers="*" secure="true" />
</cross-domain-policy>

Nothing fancy here, it's the standard setup millions of WCF services use to allow Silverlight clients to access them. Unfortunately this setup is not working in the live environment I deployed to. The pre-production environment used to test the deploy is setup identically to live (or so the sysadmins claim) and everything works perfectly there, which is why I am so confused.

I had one of the sysadmins trace the request from the Silverlight client using HTTPDebuggerPro, and it shows that the client is retrieving both clientaccesspolicy.xml and crossdomain.xml without issue (HTTP status 200). However, after requesting those files, the client tries to make a call to the service and immediately receives a CrossDomainException.

I have also tried getting the sysadmins to add the WCF service URL to Internet Explorer's "Allowed Sites" list on the box that the Silverlight client is hosted on (as per the last sentence of the last paragraph from http://blogs.msdn.com/b/fiddler/archive/2010/11/22/fiddler-and-silverlight-cross-zone-cross-domain-requests.aspx) but that didn't work either.

HALP!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

简单爱 2024-12-04 02:44:38

clientaccesspolicy.xml 是否放置在您的域的根目录中?

Is clientaccesspolicy.xml placed in the root of your domain?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文