我有一个配置了传输安全性和基本 clientCredentialType 的 Web 服务客户端。该服务正在使用 HTTPS 端点,我很难诊断错误。我试图向存储请求和响应消息以及传递的凭据(至少是用户名)的应用程序添加一个日志。
对于消息,我添加了带有 MessageInspector 的自定义行为。
我如何也可以记录凭据?WCF 中是否有任何扩展点可以做到这一点?还有什么建议吗?
谢谢
编辑:我得到的错误是这样的:
[NotSupportedException: This method is not supported by this class.]
System.Net.BasicClient.Lookup(HttpWebRequest httpWebRequest, ICredentials credentials) +2544984
System.Net.AuthenticationManager.Authenticate(String challenge, WebRequest request, ICredentials credentials) +304
System.Net.AuthenticationState.AttemptAuthenticate(HttpWebRequest httpWebRequest, ICredentials authInfo) +7949046
System.Net.HttpWebRequest.CheckResubmitForAuth() +269
System.Net.HttpWebRequest.CheckResubmit(Exception& e) +126
System.Net.HttpWebRequest.DoSubmitRequestProcessing(Exception& exception) +185
System.Net.HttpWebRequest.ProcessResponse() +75
System.Net.HttpWebRequest.SetResponse(CoreResponseData coreResponseData) +562
[WebException: The request was aborted: The request was canceled.]
System.Net.HttpWebRequest.GetResponse() +7865220
System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +99
[CommunicationException: An error (The request was aborted: The request was canceled.) occurred while transmitting data over the HTTP channel.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +4729827
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1725
...Application code from here on...
它是一个在 DEV 中正常工作但在 QA 中引发此错误的 Web 应用程序。代码相同,用户在两种环境中均有效。
绑定配置为:
<binding name="CommonBinding" maxReceivedMessageSize="10000000" useDefaultWebProxy="true" openTimeout="00:10:00" sendTimeout="00:10:00">
<security mode="Transport">
<transport clientCredentialType="Basic" proxyCredentialType="Basic"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>