2013-03-13 75 views
0

我們的應用程序通過basicHttpBinding通過WCF消費了大量Web服務。 XML消息通常非常大(> 2mb)。WCF客戶端ReaderQuota錯誤,儘管設置了上限

在運行時,我們間歇性地收到一個反序列化錯誤,它似乎與ReaderQuotas有關,它已經被設置爲Int32.MaxValue。

棧的頭部是(對不起,不得不用手從提供了一種圖像輸入它):

System.ServiceModel.Dispatcher.NetDispatcherFaultException: The formatter threw an 
exception while trying to deserializat the message: There was an error while trying to 
deserialize parameter [the namespace]. 

The InnerException message was 'There was an error deserializing the object of type 
[a type]. The maximum array length quota (5) or the maximum items in object graph 
quota has been exceeded while reading XML data. These quotas may be increased by 
changing the MaxArrayLength property on XmlDictionaryReaderQuotas or the 
MaxItemsInObjectGraph setting. Line 1, position 3645191. 

的客戶端被配置:

<client> 
     <endpoint address="http://someUri/someSvc" binding="basicHttpBinding" bindingConfiguration="SomeSvcBindingConfiguration" contract="SomeSvc" name="SomeSvc" behaviorConfiguration="ClientObjectBehavior" /> 
</client> 

<behaviors> 
     <endpointBehaviors> 
     <behavior name="ClientObjectBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="131072" /> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="SomeSvcBindingConfiguration" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:00:15" sendTimeout="00:00:15" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="10485760" maxBufferPoolSize="524288" maxReceivedMessageSize="10485760" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="false"> 
      <readerQuotas maxDepth="2147483647" 
           maxStringContentLength="2147483647" 
           maxArrayLength="2147483647" 
           maxBytesPerRead="2147483647" 
           maxNameTableCharCount="2147483647" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
      <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 

...

任何人都可以提出爲什麼這個異常可能仍然發生?

沒有任何工具可以將綁定從basicHttpBinding改變,除非它是自定義設置的一些等效組合。

回答

0

在例外消息中暗示的數字 - 「(5)」 - 實際上是MaxArrayLength設置的運行值。爲什麼在這種情況下是五,我不能確定沒有進一步的細節。

但是,圖中只有最多131072個對象可能太小 - maxItemsInObjectGraph="131072"設置。由於錯誤發生在xml內容的位置3645191處,因此我認爲該xml中可能會有比131072更多的對象。

+0

令人討厭的是,在我甚至進行此更改之前,問題已經消失並且不再可再現。 雖然你提出了一個很好的觀點,所以我要給你獎勵點數 – geoffreys 2013-03-15 05:48:14