如何解决从服务器收到的身份验证标头是“协商”内部异常:远程服务器返回错误:401未经授权
WCF: InnerException:HTTP 请求未经授权,客户端身份验证方案为“协商”。从服务器收到的身份验证标头是“协商”。 InnerException:远程服务器返回错误:(401) 未经授权。
服务器配置:
<services>
<service name="WCF.FunctionalMonitoringService">
<endpoint name="DatabaseServiceEndPoint"
address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_AppService"
contract="IdbaccessFacadeServiceContract"/>
<endpoint name="ServiceEndPoint"
address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_AppService"
contract="IServicesServiceContract"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_AppService"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
closeTimeout="00:20:00"
receiveTimeout="00:20:00"
sendTimeout="00:20:00">
<readerQuotas maxDepth="64"
maxStringContentLength="10000000"
maxArrayLength="10000000"
maxBytesPerRead="10000000"
maxNaMetableCharCount="10000000" />
<security mode="Transport">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
客户端配置:
<client>
<endpoint name="DatabaseServiceEndPoint"
address="http://***/FunctionalMonitoringService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_AppSecurityService"
contract="IdbaccessFacadeServiceContract" />
<endpoint name="ServiceEndPoint"
address="http://***/FunctionalMonitoringService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_AppSecurityService"
contract="IServicesServiceContract" />
</client>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_AppSecurityService"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
closeTimeout="00:20:00"
receiveTimeout="00:20:00"
sendTimeout="00:20:00">
<readerQuotas maxDepth="64"
maxStringContentLength="10000000"
maxArrayLength="10000000"
maxBytesPerRead="10000000"
maxNaMetableCharCount="10000000"/>
<security mode="Transport">
<transport clientCredentialType="Windows"
proxyCredentialType="None"
realm=""/>
<message clientCredentialType="UserName"
algorithmSuite="Default"/>
</security>
</binding>
<binding name="ReportingService2010Soap"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"
proxyCredentialType="None"
realm=""/>
<message clientCredentialType="UserName"
algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
我正在通过使用“ReportingService2010Soap”绑定的代码调用另一个端点。
我有两个客户端(WPF 单击一次应用程序)和一个部署了 WCF 的服务器。
客户端 1:以上代码运行良好,没有任何问题。
客户端 2:在页面加载中,我调用两个端点以验证两个端点都处于活动状态。在上面的配置中,我收到此错误并且页面本身未加载。 然后我启用了 WCF 跟踪,在调用 BasicHttpBinding_AppSecurityService 端点并抛出 InnerException:HTTP 请求未经客户端身份验证方案“协商”授权。从服务器收到的身份验证标头是“协商”。 InnerException:远程服务器返回错误:(401) 未经授权。 ReportingService2010Soap 调用返回结果。
但是 如果我删除此端点 ReportingService2010Soap 页面加载没有任何问题。
所以我很困惑错误在哪里?第一个端点或第二个端点。如果我删除第二个端点应用程序加载正常,如果我启用应用程序在第一个端点中引发错误。
我已启用 Windows 身份验证,并且提供程序在 IIS 中为“协商”。
请检查我是否遗漏了什么?
解决方法
我已确定问题并按如下方式修复。
正如我所提到的,在页面加载中首先动态调用“ReportingService2010Soap”绑定配置。调用结束此绑定对象未正确处理。 由于所有 WCF 服务调用都使用了“ReportingService2010Soap”绑定配置。
我已经通过处理绑定对象解决了这个问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。