Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 记录传递给WCF Web服务的凭据_.net_Wcf_C# 4.0_Wcf Client - Fatal编程技术网

.net 记录传递给WCF Web服务的凭据

.net 记录传递给WCF Web服务的凭据,.net,wcf,c#-4.0,wcf-client,.net,Wcf,C# 4.0,Wcf Client,我有一个配置了传输安全性和基本clientCredentialType的web服务客户端。 该服务正在使用HTTPS端点,我有一个难以诊断的错误。我试图向应用程序添加一个日志,用于存储请求和响应消息以及传递的凭据(至少是用户名)。 对于消息,我使用MessageInspector添加了一个自定义行为。 我如何也记录凭据?WCF中是否有任何扩展点可以执行此操作?还有其他建议吗? 谢谢 编辑:我得到的错误是: [NotSupportedException: This method is not su

我有一个配置了传输安全性和基本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中正常工作的web应用程序,但在QA中抛出此错误。代码相同,并且用户在两种环境中都有效

绑定配置为:

<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>

查看以下内容:


我相信您可以在IAuthorizationPolicy中执行此操作

您会遇到什么错误?您使用的是什么用户/通行证身份验证方法?据我所知,这是在服务器端。我想在客户端这样做,因为web服务不是WCF,我对它们没有太多的控制权。所以你想在客户端记录用户身份?是x.509还是用户通行证?您可以从clientCredentials行为中获取它。它是user/pass。您有没有关于如何使用clientCredentials行为进行此操作的示例?我希望捕获正在发送的有效用户和密码,而不是配置的用户和密码(无论如何,它们是在代码中设置的),如果只是用户/密码,您可以实现自定义消息编码器并通过xpath从消息中提取它们。我想说,可能有一种更优雅的方法不检查消息,但唯一确定发送内容的方法是编码器