我需要從第三方託管的Web服務下載幾十萬個實體。 Web服務允許我爲每個Web服務調用拉下多達2,000個實體,但實際上,由於我在調用更多記錄時收到的間歇性錯誤,我一次只能夠拉下50-75個實體。我試圖確定問題是由於我需要在我身邊調整的設置還是由第三方Web服務提供商提出的問題引起的。以下是我收到的錯誤:用於較大請求的WCF SOAP錯誤
接收到對 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。
你可能會打一個超時問題(無論是在客戶端或服務器端)......從請求開始發生錯誤之前需要多長時間?這很可能是服務器超時並關閉連接,因爲您要求輸入大量數據,這需要很長時間才能完成。如果您沒有受您控制的第三方網站,那麼您無法更改它的時間。你可以在時間只批量處理50條記錄嗎?在超時選項上查看。 http://www.lybecker.com/blog/2010/10/14/wcf-timeouts/ – 2012-07-31 23:18:47
如果你使用流媒體,你必須在IIS中提高極限。 http://stackoverflow.com/questions/6030137/large-binary-byte-file-transfer-through-wcf – 2012-07-31 23:27:17
我不認爲這是一個超時問題,因爲它在毫秒內失敗時,Web服務被調用。如果我請求更小的一組數據,那麼它會成功,但可能需要1-2秒的時間。 – 2012-08-06 16:42:10