c#WCF最大字符串内容长度配额

时间:2012-03-14 10:04:03

标签: c# wcf

我知道这已被贴了好几次,但我开始拉头了......我收到了以下错误:

格式化程序在尝试反序列化消息时抛出异常:反序列化操作请求消息正文时出错' CreateEmailEntry'。读取XML数据时已超出最大字符串内容长度配额(8192)。通过更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象的MaxStringContentLength属性,可以增加此配额。第157行,第92位。

这是端点配置:

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IAddEmail" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
            maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost/AutoSearchEmail/AddEmail.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAddEmail"
        contract="ServiceReference1.IAddEmail" name="BasicHttpBinding_IAddEmail" />
    </client>
  </system.serviceModel>

以下是WCF项目的配置:

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IAddEmail" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
            maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

我读了很多帖子,说&#34;增加maxStringContentLength&#34;我相信我有,但最可能的是我忽略了......

我真的不喜欢在代码中创建端点的想法 - 听起来像是另外一层出错的其他层!

提前致谢。

1 个答案:

答案 0 :(得分:1)

对于服务配置,这是您的整个配置,因为我错过了

 <services>

您将绑定应用于服务的部分。