连接WCF服务错误:调用方未由服务进行身份验证,无法满足对安全令牌的请求
相关错误提示:
调用方未由服务进行身份验证,无法满足对安全令牌的请求,因为身份验证失败。
InnerException = {"为验证提供的消息或签名已被改变"}
SOAP security negotiation with 'http://192.168.0.118/CSFramework/CommonService.svc' for target 'http://192.168.0.118/CSFramework/CommonService.svc' failed. See inner exception for more details.
解决方案
1. 修改服务端Web.Config文件,在binding内加<security mode="None"/>,不需要验证用户,因为开发框架内部有安全验证机制。
<bindings>
<wsHttpBinding>
<binding name="ICommonService" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" receiveTimeout="04:00:00" sendTimeout="00:03:00" >
<readerQuotas maxDepth="6553600" maxStringContentLength="2147483647" maxArrayLength="214748364
7" maxBytesPerRead="6553600" maxNameTableCharCount="6553600"/>
<reliableSession ordered="true" inactivityTimeout="04:00:00" enabled="true" />
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
2. 修改客户端App.Config配置文件,在binding内指定安全验证<security mode="None"/>
<binding name="WSHttpBinding_ICommonService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="04:00:00" sendTimeout="00:03:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="6553600" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="6553600" maxNameTableCharCount="6553600" />
<reliableSession ordered="true" inactivityTimeout="04:00:00"
enabled="true" />
<security mode="None"/>
</binding>