WPF客户端 - WCF允许跨域访问 - 问题
问题描述:
我真的很苦恼这个。我已经谷歌这一点,并尝试了大部分解决方案没有取得任何成功。WPF客户端 - WCF允许跨域访问 - 问题
一些背景资料:
我有一个WPF应用程序消耗WCF服务。如果服务和应用程序位于同一个域中,一切正常,但只要将应用程序移动到另一个域,它就会停止wokiring并提供以下错误:
安全令牌的请求无法满足,因为认证失败。
我通过以下文章:跨域边界提供服务[^],它涉及到使用某些XML文件,我曾尝试将XML文件(clientaccesspolicy.xml和crossdomain。 xml)在IIS服务器上 - 这没有任何区别(请注意,我确实将文件放在Web服务的根目录中)?
我可以访问Web服务(客户端),通过在浏览器中输入URL以及点击wsdl链接并查看XML,但是我无法从我的WPF应用程序中使用它!
这是我的客户端配置文件的内容:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IManagmentService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://server.local/ManagementDataProvider/ManagmentService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IManagmentService"
contract="ManagementService.IManagmentService" name="WSHttpBinding_IManagmentService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
任何人都可以请提供给我的我如何从我的应用程序访问Web服务的一些信息。
非常感谢提前! 亲切的问候,
答
好的,所以这个问题通过使用(http://msdn.microsoft.com/en-us/library/ms731361.aspx)解决。这个问题与跨域访问无关。 (http://msdn.microsoft.com/en-us/library/ms731299.aspx)需要由安全令牌满足,从而访问来自未知域(DNS未知)的Web服务。
那么,这是什么解决了我的问题?
亲切的问候,
如果您通过浏览器调用服务,它是否提示您输入用户名/密码?我假设托管服务的域名和托管客户端的域名不存在信任关系,因此您的服务无法验证客户端。 – Dominik
你可以发布你的'clientaccesspolicy.xml'和'crossdomain.xml'的内容吗? – Rachel
而且这是否与一个普通的非安全绑定工作?一个没有传输和消息安全性? (请参阅http://stackoverflow.com/q/394829/302677) – Rachel