2013-03-13 77 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