SilverLight跨域访问WCF时,出现:
尝试向 URI“*******”发出请求时出错。这可能是由于试图以跨域方式访问服务而又没有正确的跨域策略,或策略不适用于 SOAP 服务。您可能需要与该服务的所有者联系,以发布跨域策略文件并确保该文件允许发送 SOAP 相关的 HTTP 标头。出现此错误也可能是由于使用的是 Web 服务代理中的内部类型而没有使用 InternalsVisibleToAttribute 属性。有关详细信息,请参阅内部异常。
这是一个Silverlight 跨域的策略问题,将策略文件clientaccesspolicy.xml 和 crossdomain.xml放在网站根目录下 (C:\Inetpub\wwwroot),文件编码为 utf-8;文件内容如下:
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" encoding="utf-8" ?>
<cross-domain-policy>
<allow-access-from domain="localhost" />
<allow-access-from domain="192.168.1.8" />
</cross-domain-policy>