更大请求的WCF SOAP错误

时间:2012-07-27 19:27:50

标签: wcf web-services binding

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

  

接收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。

1 个答案:

答案 0 :(得分: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>