当negotiateServiceCredential设置为false WCF client gets时:从另一方接收到不安全或安全性不正确的故障
我构建了一个使用wsHttpBinding的WCF服务和一个调用它的客户端。当negotiateServiceCredential设置为false WCF client gets时:从另一方接收到不安全或安全性不正确的故障,wcf,wcf-security,wcf-client,wshttpbinding,Wcf,Wcf Security,Wcf Client,Wshttpbinding,我构建了一个使用wsHttpBinding的WCF服务和一个调用它的客户端。 但我仍然收到以下错误消息: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. 内部的例外是: An error occurred when processing the security toke
但我仍然收到以下错误消息:
An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
内部的例外是:
An error occurred when processing the security tokens in the message.
以下是服务的配置文件:
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="myWsBinding">
<security>
<message negotiateServiceCredential="false" algorithmSuite="Basic128"
establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="HelloWorldService.HelloService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="myWsBinding"
contract="HelloWorldService.IHelloService">
<identity>
<servicePrincipalName value="host/MAGBAREYA"/>
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8999/myService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
下面是客户端配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IHelloService">
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="false"
algorithmSuite="Basic128" establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8999/myService" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IHelloService" contract="ServiceReference1.IHelloService"
name="WSHttpBinding_IHelloService">
<identity>
<servicePrincipalName value="host/MAGBAREYA"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
有问题的配置是:negotiateServiceCredential=“false”。
如果我在服务和客户机中都将其设置为true,那么客户机将能够完美地工作。(使用上述配置文件,但此更改除外) 谁能告诉我这里错过了什么
提前感谢。我会尝试启用更多日志记录。在服务器上,您可以在服务的配置文件中启用整个WCF消息的日志记录,如下所示,以启动:
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="messages"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\logs\messages.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="false"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="false"
maxMessagesToLog="3000"
maxSizeOfMessageToLog="2000"/>
</diagnostics>
</system.serviceModel>
执行此操作后,您可以再次测试客户端以重新创建异常,并使用工具svctraceviewer检查.svclog文件。以下链接应详细解释此操作:在服务器上打开wcf跟踪以获取详细错误