【发布时间】:2012-07-27 19:27:50
【问题描述】:
我需要从第三方托管的网络服务下载几十万个实体。 Web 服务允许我每次调用 Web 服务最多下拉 2,000 个实体,但实际上我一次只能下拉 50-75 个实体,因为当我调用更多记录时会收到间歇性错误。我正在尝试确定问题是否是由于我需要调整的设置,或者问题是否与第 3 方网络服务提供商有关。这是我收到的错误:
接收到的 HTTP 响应时出错 https://some.vendor.com/API/SomeService.svc。这可能是由于 服务端点绑定不使用 HTTP 协议。这也可以 是由于服务器中止了 HTTP 请求上下文 (可能是由于服务关闭)。查看服务器日志了解更多信息 详情。
以下是我用于绑定 Web 服务的应用程序配置设置的副本:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="SomeService">
<security defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport"
requireDerivedKeys="true" securityHeaderLayout="Strict" includeTimestamp="true"
keyEntropyMode="CombinedEntropy" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings cacheCookies="true" detectReplays="false"
replayCacheSize="900000" maxClockSkew="00:05:00" maxCookieCachingTime="Infinite"
replayWindow="00:05:00" sessionKeyRenewalInterval="10:00:00"
sessionKeyRolloverInterval="00:05:00" reconnectTransportOnFailure="true"
timestampValidityDuration="00:05:00" cookieRenewalThresholdPercentage="60" />
<localServiceSettings detectReplays="false" issuedCookieLifetime="10:00:00"
maxStatefulNegotiations="128" replayCacheSize="900000" maxClockSkew="00:05:00"
negotiationTimeout="00:01:00" replayWindow="00:05:00" inactivityTimeout="00:02:00"
sessionKeyRenewalInterval="15:00:00" sessionKeyRolloverInterval="00:05:00"
reconnectTransportOnFailure="true" maxPendingSessions="128"
maxCachedCookies="1000" timestampValidityDuration="00:05:00" />
<secureConversationBootstrap />
</security>
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap11" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpsTransport manualAddressing="false" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Streamed" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" requireClientCertificate="false" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://secure.Some.com/API/1.2/Service.svc"
binding="customBinding" bindingConfiguration="SomeService"
contract="SomeService.SomeService" name="SomeService" />
</client>
</system.serviceModel>
正如您在应用程序配置绑定中看到的,我将 maxBufferPoolSize、maxReceivedMessageSize 和 maxBufferSize 增加到 2147483647。我还将 transferMode 更改为 Streamed。
【问题讨论】:
-
您可能遇到超时问题(在客户端或服务器端)...从您的请求开始发生错误需要多长时间?更有可能是服务器超时并关闭连接,因为您要求大量数据需要很长时间才能完成。如果您无法控制第三方网站,则无法更改其时间。您可以一次批处理 50 条记录吗?请参阅超时选项。 lybecker.com/blog/2010/10/14/wcf-timeouts
-
如果您使用流媒体,则必须提高 IIS 的限制。 stackoverflow.com/questions/6030137/…
-
我认为这不是超时问题,因为它会在调用 Web 服务的几毫秒内失败。如果我请求一组较小的数据,则它会成功,但可能需要 1-2 秒以上。
-
你能获得多大的信息?
标签: wcf web-services binding