WCF客户端和服务器端不在同一台机器上时,客户端调用服务器端会报如下错误:"服务器已拒绝客户端凭据"。
解决办法:
1、右击ServiceHost项目的App.config文件>>编辑WCF配置>>绑定>>右击:新建绑定配置,Name设为BindingBehaviorConfiguration;安全性:Mode设为None。这样在
App.config文件中会生成如下代码:
<
bindings
>
< netTcpBinding >
< binding maxBufferPoolSize = " 52428800 " maxBufferSize = " 6553600 " maxReceivedMessageSize = " 6553600 " portSharingEnabled = " true " >
< readerQuotas maxStringContentLength = " 6553600 " />
<!-- 取消服务器凭据认证 -->
< security mode = " None " />
</ binding >
</ netTcpBinding >
</ bindings >
< services >
< service name = " ServiceUser " >
< endpoint binding = " netTcpBinding " name = " ServiceUser " contract = " ServiceUser_NetTCP.IServiceUser " />
</ service >
</ services >
< netTcpBinding >
< binding maxBufferPoolSize = " 52428800 " maxBufferSize = " 6553600 " maxReceivedMessageSize = " 6553600 " portSharingEnabled = " true " >
< readerQuotas maxStringContentLength = " 6553600 " />
<!-- 取消服务器凭据认证 -->
< security mode = " None " />
</ binding >
</ netTcpBinding >
</ bindings >
< services >
< service name = " ServiceUser " >
< endpoint binding = " netTcpBinding " name = " ServiceUser " contract = " ServiceUser_NetTCP.IServiceUser " />
</ service >
</ services >
2、重新引用服务;
3、客户端调用服务config处复制生成的服务配置文件并。其实重点主要是修改了:
<security mode="Transport"> 修改了 <security mode="None">