读取XML数据时,已超过最大字符串内容长度配额(8192)。可以通过更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象上的MaxStringContentLength属

原始异常:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:CheckedResult. The InnerException message was 'There was an error deserializing the object of type SDTool.VFRService.CheckedResponse. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 18538.'.  Please see InnerException for more details. ---> System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type SDTool.IVFRService.CheckedResponse. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 18538. ---> System.Xml.XmlException: The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 18538

原因分析:

在WCF中已经配置如下配置:

<bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IReseiverService" receiveTimeout="00:10:00" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:05:00" maxBufferPoolSize="1048576000" maxReceivedMessageSize="1048576000">
          <readerQuotas maxDepth="640" maxStringContentLength="1048576000" maxArrayLength="1048576000" maxBytesPerRead="1048576000" maxNameTableCharCount="1048576000"/>
          <security mode="None">
            <message clientCredentialType="UserName"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
在客户端的配置如下:

<binding name="BasicHttpBinding_IReseiverService"  maxReceivedMessageSize="104857600">
        </binding>
在windows10系统中运行,客户端能正常访问,但是在windows7系统中就会出现上面的异常信息,通过尝试,需在客户端配置与服务端一样的配置。结果如下:

<binding name="BasicHttpBinding_IReseiverService"  maxReceivedMessageSize="104857600">
          <readerQuotas maxDepth="640" maxStringContentLength="1048576000" maxArrayLength="1048576000" maxBytesPerRead="1048576000" maxNameTableCharCount="1048576000"/>
        </binding>

在交给客户使用后不久又出现以下问题:

The formatter threw an exception while trying to deseriabize the message:There was an error while trying to deserialize parameter http://tempuri.org/:QueryRecordResult.The InnerException message was'Maxinum number of items that can be serialized or deserialized in an object graph is '65536'.Change the object praph or increase the MaxItemInObjectGraph quota.'.Please see InnerException for more details.

在客户端配置文件节点system.serviceModel增加一个名称为NewBehavior的节点

<behaviors>
      <endpointBehaviors>
        <behavior name="NewBehavior">
          <dataContractSerializer maxItemsInObjectGraph="65536000" />
        </behavior>
      </endpointBehaviors>
    </behaviors>

同时在client节点的endpoint节点内怎加如下配置,跟上面内容关联。
behaviorConfiguration="NewBehavior",配置结果如下

<endpoint address="http://127.0.0.1:9371/ReseiverService.svc" behaviorConfiguration="NewBehavior"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IReseiverService"
        contract="IDCardService.IReseiverService" name="BasicHttpBinding_IReseiverService" />

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

likedefly

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值