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节点都加上。
问题解决。