首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF wsHttpBindingwith silverlight中的跨域错误

WCF wsHttpBindingwith silverlight中的跨域错误
EN

Stack Overflow用户
提问于 2013-12-14 13:30:24
回答 2查看 2.1K关注 0票数 2

我有一个WCF服务,并且我在web.config中使用wsHttpBinding

我还从IIS7创建了一个测试证书,并将其用于网站的https绑定

服务的Web配置如下

代码语言:javascript
复制
<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>

当我在浏览器中打开URL时,它工作得很好,当我向silverlight项目添加服务引用时,它也工作得很好。

但是,当我从应用程序调用服务时,它会给出一个跨域错误。

我还在项目中包含了clientaccesspolicy.xmlcrossDomain.xml,但仍然面临一个问题

代码语言:javascript
复制
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.

EN

回答 2

Stack Overflow用户

发布于 2013-12-14 22:26:11

clientaccesspolicy.xml需要位于web服务器的根目录中,而不是您的项目中。

http://msdn.microsoft.com/en-us/library/cc197955(v=vs.95).aspx

3.将crossdomain.xml文件保存到托管服务的域的根目录。例如,如果服务托管在http://fabrikam.com中,则文件必须位于http://fabrikam.com/crossdomain.xml

票数 0
EN

Stack Overflow用户

发布于 2017-02-20 18:20:37

您需要在您托管在IIS上的clientaccesspolicy.xml服务的根文件夹中添加crossDomain.xml和WCF。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20580014

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档