【发布时间】:2012-07-23 15:55:51
【问题描述】:
我有一个使用带有消息加密的 wsHttpBinding 的 WCF 服务。我使用相同的服务引用,除非它出现故障,在这种情况下我创建一个新的。我遇到了一个问题,即会话已超时且服务已结束,但客户端应用程序的 CommunicationState 仍为 Opened。
如何在 ClientBase 中判断连接是否超时?如果当前服务代理已超时,我希望在我的客户端应用程序中创建一个新的服务代理。
下面是我的客户端绑定:
<wsHttpBinding>
<binding name="wsHttpBindingWithAuthClient" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="20000000"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
【问题讨论】:
-
为什么不能每次都新建代理?
-
我必须每次都设置我的 ClientCredentials 和 ServiceCertificate 字段。我不确定每次通话都这样做的后果。
标签: c# wcf wshttpbinding