【发布时间】:2011-05-31 03:12:49
【问题描述】:
我们有一个进行 WCF 服务调用的 Windows 服务。通常,它工作正常。但是,偶尔当我们重新启动 Windows 服务时,会抛出一个MessageSecurityException,然后一切都在折腾,之后又被反复抛出。
我们找到的一个解决方案是将AllowedImpersonationLevel 设置为“模拟”。但是,我们不使用任何模拟。此外,这是一个随机问题,并不总是可重现的。因此,这个解决方案将是无关紧要的。
如果有人能对此有所了解,我们将不胜感激。
错误信息的堆栈跟踪:
2010-12-24 23:18:42,581 [3] 错误 [DataSync] – 期间发生错误 数据同步 [(null)] System.ServiceModel.Security.MessageSecurityException: HTTP 请求未经授权 客户端认证方案 '谈判'。身份验证标头 从服务器收到的是 “谈判,NTLM”。 -> System.Net.WebException:远程 服务器返回错误:(401) 未经授权。在 System.Net.HttpWebRequest.GetResponse() 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度 timeout) — 内部异常堆栈结束 追踪 --
服务器堆栈跟踪:在 System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest 请求,HttpWebResponse 响应, WebException 响应异常, HttpChannelFactory 工厂)在 System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest 请求,HttpWebResponse 响应, HttpChannelFactory 工厂, WebException 响应异常, 通道绑定通道绑定)在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度 超时)在 System.ServiceModel.Channels.RequestChannel.Request(消息 消息,TimeSpan 超时)在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息 消息,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串 动作,单向布尔值, ProxyOperationRuntime 操作, Object[] 输入,Object[] 输出,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串 动作,单向布尔值, ProxyOperationRuntime 操作, Object[] 输入,Object[] 输出)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage 方法调用、代理操作运行时 操作)在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 留言)
【问题讨论】:
-
对面的 WCF 服务是否托管在 IIS 中?如果是,那么在 IIS 日志中检查用户记录的失败请求?
标签: c# wcf exception windows-services wcf-security