WCF配置文件 - 以及着名的"字符串内容长度配额(8192)"错误

Tom*_*omK 6 iis wcf app-config web-config

伙计们,

感谢您对我以前的WCF配置文件问题的帮助.这是一个新的.

我的项目是一个WinForms应用程序客户端(.NET 4.0),它从IIS 7.0上托管的WCF服务中提取数据(并将其保存到).当我保存一个小的有效载荷时,一切都很好.当我尝试将有效负载保存超过8192字节时,错误是:

格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数http://tempuri.org/:objEncounterType时出错 .InnerException消息是'反序列化PsychCoverage.Common.EncounterType类型的对象时出错.读取XML数据时已超出最大字符串内容长度配额(8192).通过更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象的MaxStringContentLength属性,可以增加此配额.第1行,位置10809.'.有关更多详细信息,请参阅InnerException

我已经证实我和我<binding name="">的一样<endpoint bindingConfiguration="">.

我已经把我maxReceivedMessageSizemaxBufferPoolSizemaxBufferSize所有10,000,000我的两个客户端app.config和我的web.config.我试着让我的<readerQuota>价值观非常高涨.

在我的web.config中设置 <httpRuntime maxRequestLength="10000000" />

这是来自我的客户app.config:

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="wcfAdmin_binding"           
             maxReceivedMessageSize="10000000" 
             maxBufferPoolSize="10000000" 
             maxBufferSize="10000000" 
             messageEncoding="Text" 
             sendTimeout="00:05:00" 
             receiveTimeout="00:05:00"
             bypassProxyOnLocal="false" 
             hostNameComparisonMode="StrongWildcard"
             textEncoding="utf-8" 
             useDefaultWebProxy="true" 
             allowCookies="false"
             >
      <readerQuotas maxDepth="200" maxStringContentLength="10000000" maxArrayLength="16384" maxBytesPerRead="10000000" maxNameTableCharCount="16384" />
      <security mode="None"></security>
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <clear/>
  <endpoint address="http://localhost/PsychCoverage/Admin.svc" name="AdminUIClientEndpoint" binding="basicHttpBinding" bindingConfiguration="wcfAdmin_binding" contract="PsychCoverage.Common.IAdmin">
    <identity>
      <dns value="localhost" />
    </identity>
  </endpoint>
</client>

</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

这是来自我的服务web.config:

<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="False" ></serviceHostingEnvironment>
<bindings>
  <basicHttpBinding>
    <binding name="wcfAdmin_binding"  
             maxReceivedMessageSize="10000000" 
             maxBufferPoolSize="10000000" 
             maxBufferSize="10000000" 
             messageEncoding="Text" 
             sendTimeout="00:05:00" 
             receiveTimeout="00:05:00">
      <readerQuotas maxDepth="200" 
                    maxStringContentLength="10000000" 
                    maxArrayLength="16384" 
                    maxBytesPerRead="10000000" 
                    maxNameTableCharCount="16384" />
      <security mode="None"></security>
    </binding>
    <binding name="wcfClientWebPortal_binding" 
              maxReceivedMessageSize="10000000" 
              maxBufferPoolSize="10000000" 
              maxBufferSize="10000000" 
              messageEncoding="Text" 
              sendTimeout="00:05:00" 
              receiveTimeout="00:05:00">
      <readerQuotas maxDepth="200" 
                    maxStringContentLength="10000000" 
                    maxArrayLength="16384" 
                    maxBytesPerRead="10000000" 
                    maxNameTableCharCount="16384" />
      <security mode="None"></security>
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="wcfBehavior" name="PsychCoverage.WcfMT.Admin">
    <endpoint address="" 
              binding="basicHttpBinding" 
              bindingConfiguration="wcfAdmin_binding"
              name="AdminEndpoint" 
              bindingName="wcfAdmin_binding" 
              contract="PsychCoverage.Common.IAdmin">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
  </service>
  <service behaviorConfiguration="wcfBehavior" name="PsychCoverage.WcfMT.ClientWebPortal">
    <endpoint address="" 
              binding="basicHttpBinding"
              bindingConfiguration="wcfClientWebPortal_binding"
              name="ClientWebPortalEndpoint" 
              bindingName="wcfClientWebPortal_binding"
              contract="PsychCoverage.Common.IClientWebPortal">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="wcfBehavior">
      <!-- To avoid disclosing metadata information, 
      set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="False" />
      <!-- To receive exception details in faults for debugging purposes, 
      set the value below to true.  Set to false before deployment 
      to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100" maxConcurrentInstances="100" />
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

提前谢谢了.