我已经成功创建并且目前正在使用 clientaccesspolicy.xml 文件将我的 WCF 公开给我的 Silverlight 客户端,其允许域 uri 为http://*
. 我想通过使用更具体的 uri(如http://www.foobar.com
or )来加强它http://*.foobar.com
,但是当我使用这些 uri 时,我的 Silverlight 客户端中会出现 SecurityExceptions。
作为参考,这里是当前工作的 clientaccesspolicy.xml:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="http://*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
我尝试将 http-request-headers 更改为“*”无济于事。而且我已经验证了通配符 uris(和资源路径)在保护 .txts 或 .pngs 等非 WCF 资源时对我有用。我的 clientaccesspolicy.xml 与 .svc 位于同一目录中。
我不能使用 crossdomain.xml,因为它不允许特定的 uris(请参阅http://msdn.microsoft.com/en-us/library/cc838250(VS.95).aspx)。
谢谢!