gpt4 book ai didi

.net - WCF wsHttpBinding 与 http keepalive

转载 作者:行者123 更新时间:2023-12-04 00:20:08 32 4
gpt4 key购买 nike

我有一个使用 wsHttpBinding 的 WCF 客户端,我想启用 http keep-alive。

我希望我可以通过更改客户端配置来打开它...我找到了很多关于如何为 basicHttp 绑定(bind)打开 keep-alives 的描述,但是 wsHttpBinding 没有运气...这可能吗?

非常感谢。

这是我的客户端绑定(bind):

  <wsHttpBinding>
<binding name="WSHttpBinding_IRepositoryService" closeTimeout="00:00:10"
openTimeout="00:00:10" receiveTimeout="00:05:00" sendTimeout="00:05:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="655360" messageEncoding="Mtom"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="81920" maxArrayLength="163840"
maxBytesPerRead="409600" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="true" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>

</binding>
</wsHttpBinding>

最佳答案

您必须使用 custom binding为了禁用 Keep-Alive header ,因为该功能未在任何内置绑定(bind)类中公开。

无需从头定义自定义绑定(bind)即可实现此目的的最简单方法是自定义现有的 BasicHttpBindingWSHttpBinding与代码中的客户端代理关联的实例。

这是一个例子:

var proxy = new MyServiceClient();
var customBinding = new CustomBinding(proxy.Endpoint.Binding);
var transportElement = customBinding.Elements.Find<HttpTransportBindingElement>();
transportElement.KeepAliveEnabled = false;

proxy.Endpoint.Binding = customBinding;

关于.net - WCF wsHttpBinding 与 http keepalive,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6535074/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com