WCF:读取 XML 数据时已超出最大字符串内容长度配额 (8192)

WCF: The maximum string content length quota (8192) has been exceeded while reading XML data

在搜索了 Internet 和 Whosebug 之后,我还没有找到可行的解决方案。尝试读取我收到的响应时,内部异常是:

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.

我是联系服务器的客户端,我收到回复,在查看回复后,它比 8192 限制大得多。我已将我的客户端配置更新到最大级别,但没有帮助。我不知道在哪里更新限制,所以任何帮助将不胜感激:

客户端配置:

<configuration>
  <system.serviceModel>
    <client>
      <endpoint name="CaqhCore_EndpointWithCertificates" address="https://MyEndPoint" behaviorConfiguration="Cbc_BehaviorWithCertificateSigning" binding="customBinding" bindingConfiguration="Cbc_BindingWithCertificates" contract="CORETransactions">
        <identity>
          <certificateReference findValue="1h 1h 1h 1h 1h 1h 1h 1h 1h 1h" x509FindType="FindByThumbprint" />
        </identity>
      </endpoint>
    </client>
    <bindings>
      <customBinding>
        <binding name="Cbc_BindingWithCertificates" maxReceivedMessageSize="2147483647">
          <security enableUnsecuredResponse="false" allowSerializedSigningTokenOnReply="true" authenticationMode="MutualCertificate" requireDerivedKeys="false" includeTimestamp="true" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
            <issuedTokenParameters keyType="AsymmetricKey" />
            <secureConversationBootstrap>
              <issuedTokenParameters keyType="AsymmetricKey" />
            </secureConversationBootstrap>
          </security>
          <textMessageEncoding messageVersion="Soap12WSAddressingAugust2004" writeEncoding="utf-8">
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          </textMessageEncoding>
          <httpsTransport />
        </binding>
      </customBinding>
    </bindings>
  </system.serviceModel>
</configuration>

请注意,由于隐私问题,我已经从配置中删除了我认为不相关的信息,但如果您需要查看其他部分(例如行为或其他元素),请告诉我。

我找到了答案。问题是我正在使用的代码(不是我写的)包含对象的代码:XmlDictionaryReaderQuotas 被注释掉了,这意味着它无法从配置文件,因此使用默认值。