WCF客户端和服务器端不在同一台机器上时,客户端调用服务器端会报如下错误:"服务器已拒绝客户端凭据"。
解决办法:
1、右击ServiceHost项目的App.config文件>>编辑WCF配置>>绑定>>右击:新建绑定配置,Name设为BindingBehaviorConfiguration;安全性:Mode设为None。这样在
App.config文件中会生成如下代码:
<binding name="BindingBehaviorConfiguration">
<security mode="None">
<transport clientCredentialType="Windows" />
<message clientCredentialType="Windows" />
</security>
</binding>
2、在<endpoint binding="netTcpBinding" contract="WCF.ServiceLib.Binding.IHello" address="net.tcp://192.168.1.110:54321/Binding/Hello"/>
处增加 bindingConfiguration="BindingBehaviorConfiguration":
<endpoint binding="netTcpBinding" contract="WCF.ServiceLib.Binding.IHello" address="net.tcp://192.168.1.110:54321/Binding/Hello" bindingConfiguration="BindingBehaviorConfiguration"/>
3、在Client项目App.config文件中作相同操作。
OK,搞定!