C#报错: The maximum string content length quota (8192) has been exceeded while reading XML data

C#客户端,调用别家的webservice,返回信息报错,摘取其中重要的如下:

The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property

不过这个问仅仅出现在Win XP系统,同样的调用在WIn 7和Win 10上没有出现。

这个问题曾经解决过,是通过修改配置文件,增加<readerQuotas>节点解决的。不过这次用“同样的方法”却问题依旧。

 经过一番探索,找到了办法,其实还是增加<readerQuotas>节点,但需要加在正确的<binding>节点中。正确的配置文件如下:

<basicHttpBinding>
    <binding name="sDataInfraceSoap" />
    <binding name="instrumentDockingServiceProviderServiceBinding">
			<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
				maxArrayLength="2147483647" maxBytesPerRead="2147483647"
				maxNameTableCharCount="2147483647" />
     </binding>
     <binding name="sDataInfraceSoap1" />
      <binding name="sDataInfraceSoap2" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" >
			<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
				maxArrayLength="2147483647" maxBytesPerRead="2147483647"
				maxNameTableCharCount="2147483647" />
	</binding>
    <binding name="StandardInterfaceSoap11Binding" />
</basicHttpBinding>

本项目比较特殊,一个软件集成了多个别家的webservice,所有配置文件里面的binding节点很多,这里就有四种:

sDataInfraceSoap

instrumentDockingServiceProviderServiceBinding

sDataInfraceSoap1

sDataInfraceSoap2

在<client>节点中确认一下报错的调用匹配的是哪一个binding:

<client>
      <endpoint address="http://aaa" binding="basicHttpBinding" bindingConfiguration="sDataInfraceSoap" contract="ServiceEtMobile.sDataInfraceSoap" name="sDataInfraceSoap" />
      <endpoint address="http://bbb" binding="basicHttpBinding" bindingConfiguration="sDataInfraceSoap1" contract="ServiceEtMobile2018.sDataInfraceSoap" name="sDataInfraceSoap1" />
      <endpoint address="http://xxx" binding="basicHttpBinding" bindingConfiguration="instrumentDockingServiceProviderServiceBinding" contract="ServiceZYD.instrumentDockingServiceProvider" name="instrumentDockingServiceProviderService" />
      <endpoint address="http://kkk" binding="basicHttpBinding" bindingConfiguration="sDataInfraceSoap2" contract="ServiceEtMobile2.sDataInfraceSoap" name="sDataInfraceSoap2" />
      <endpoint address="http://iii" binding="basicHttpBinding" bindingConfiguration="StandardInterfaceSoap11Binding" contract="ServiceJSSYJ_STD_Test.StandardInterfacePortType" name="StandardInterfaceHttpSoap11Endpoint" />
      <endpoint address="http://ttt" binding="customBinding" bindingConfiguration="StandardInterfaceSoap12Binding" contract="ServiceJSSYJ_STD_Test.StandardInterfacePortType" name="StandardInterfaceHttpSoap12Endpoint" />
</client>

也就是说,<readerQuotas>节点要加在对应的binging节点中才有效。当然,笨办法就是几个binding节点都加上。

问题解决。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

小鹰信息技术服务部

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

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

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

打赏作者

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

抵扣说明:

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

余额充值