2013-12-14 73 views
2

我有一个WCF服务,我在web.config中使用wsHttpBindingWCF中的跨域错误wsHttpBindingwith silverlight

我也从IIS7创建了一个测试证书,并用它为HTTPS当我打开它完美浏览器的网址与网站服务的

Web配置如下

<system.serviceModel> 
    <behaviors> 
    <serviceBehaviors> 
    <behavior name="WsBehaviour"> 
    <serviceMetadata httpsGetEnabled="true"/> 
    <serviceDebug includeExceptionDetailInFaults="false"/> 
    </behavior> 
    </serviceBehaviors> 
    </behaviors> 

    <bindings> 
    <wsHttpBinding> 
    <binding name="WsBinding"> 
     <security mode="Transport"> 
     <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
     <message clientCredentialType="None" algorithmSuite="Default" />   
     </security>    
    </binding> 
    </wsHttpBinding>  
    </bindings> 

    <services> 
    <service name="WsService.Service1" behaviorConfiguration ="WsBehaviour"> 
    <endpoint address="https://MachineName.DomainName:8087/WsService/Service1.svc" 
     binding="wsHttpBinding" bindingConfiguration="WsBinding" contract="WsService.IService1" > 

     <identity> 
     <dns value="localhost" /> 
     </identity> 

    </endpoint> 
    </service> 
    </services> 
</system.serviceModel> 

结合,并且在向Silverlight项目添加服务引用时也可以很好地工作。

但是当我从应用程序调用服务时,它会产生跨域错误。

我还包括clientaccesspolicy.xml并在项目crossDomain.xml,但仍然面临一个问题

An error occurred while trying to make a request to URI 
'https://MachineName.DomainName:8087/WsService/Service1.svc'. This 
could be due to attempting to access a service in a cross-domain way 
without a proper cross-domain policy in place, or a policy that is 
unsuitable for SOAP services. You may need to contact the owner of the 
service to publish a cross-domain policy file and to ensure it allows 
SOAP-related HTTP headers to be sent. This error may also be caused by 
using internal types in the web service proxy without using the 
InternalsVisibleToAttribute attribute. Please see the inner exception 
for more details. 

enter image description here

回答

0

您需要将IIS访问的WCF服务的根文件夹中添加clientaccesspolicy.xml和crossDomain.xml。