0

我需要从第三方托管的 Web 服务下载几十万个实体。Web 服务允许我每次调用 Web 服务最多下拉 2,000 个实体,但实际上我一次只能下拉 50-75 个实体,因为当我调用更多记录时会收到间歇性错误。我正在尝试确定问题是否是由于我需要调整的设置,或者问题是否与第 3 方网络服务提供商有关。这是我收到的错误:

接收对 https://some.vendor.com/API/SomeService.svc的 HTTP 响应时出错。这可能是由于服务端点绑定未使用 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。

4

1 回答 1

0

还有一个重要的设置可以通过添加一个行为来设置:

<behaviors>
  <endpointBehaviors>
    <behavior name="SomeBehavior">
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </endpointBehaviors>
</behaviors>

然后,更新您的端点:

<client>
  <endpoint address="https://secure.Some.com/API/1.2/Service.svc"
     binding="customBinding" bindingConfiguration="SomeService"
     contract="SomeService.SomeService" name="SomeService"
     **behaviorConfiguration="SomeBehavior"**/>
</client>
于 2012-07-27T20:48:54.997 回答