我们的应用程序通过basicHttpBinding在WCF上消耗了许多Web服务。 XML消息通常非常大(> 2mb)。
在运行时,我们间歇性地收到反序列化错误,该错误似乎与已经设置为Int32.MaxValue的ReaderQuotas有关。
堆叠的头部(抱歉,必须从提供的图像中手动输入):
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 :(得分:0)
异常消息中提示的数字 - “(5)” - 实际上是MaxArrayLength设置的运行值。为什么在这种情况下它是五,我无法确定没有进一步的细节。
但是,图表中最多只有131072个对象可能太小 - maxItemsInObjectGraph="131072"
设置。由于错误发生在xml内容的位置3645191,我假设xml中的对象可能比131072更多。