尝试向 URI“http://localhost:8001/AccountService.svc”发出请求时出错。这可能是由于试图以跨域方式访问服务而又没有正确的跨域策略,或策略不适用于 SOAP 服务。您可能需要与该服务的所有者联系,以发布跨域策略文件并确保该文件允许发送 SOAP 相关的 HTTP 标头。出现此错误也可能是由于使用的是 Web 服务代理中的内部类型而没有使用 InternalsVisibleToAttribute 属性。有关详细信息,请参阅内部异常。
解决方法:
一、在WCF项目根目录下添加clientaccesspolicy.xml文件
二、在silverlight项目中添加一个中介类ServerManager.cs
三、实例化实体类的时候一般是这样:ServiceWcfClient clientWcf = new ServiceWcfClient();
换成:ServiceWcfClient clientWcf = ServerManager.GetPox();
PS:下面是原创内容了
事实证明,仅仅添加一项clientaccesspolicy.xml是不够的,还要配置一下WCF下面的web.config文件,添加services节点,下面贴代码:
<services>
<service behaviorConfiguration="WcfService1.Service1Behavior" name="WcfService1.Service1">
<endpoint binding="basicHttpBinding" bindingConfiguration="" contract="WcfService1.IService1" >
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
</services>