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



在搜索了互联网和StackOverflow之后,我还没有找到一个有效的解决方案。当试图读取我得到的响应时,内部异常是:

读取XML数据时超过了最大字符串内容长度配额(8192)。可以通过更改创建XML读取器时使用的XmlDictionaryReaderQuotas对象的MaxStringContentLength属性来增加此配额。

我是一个联系服务器的客户,在查看响应后,我收到的响应远远大于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被注释掉了,这意味着它无法从配置文件中读取readerQuotas节点,因此使用默认值。

最新更新