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

时间:2011-08-30 05:08:08

标签: wcf iis web-config app-config

民间,

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

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

  

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

我已确认我的<binding name="">与我的<endpoint bindingConfiguration="">相同。

我已在我的客户maxReceivedMessageSizemaxBufferPoolSize上将maxBufferSizeapp.config以及web.config全部设置为10,000,000。我尝试将<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>

这来自我的服务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>

非常感谢提前。

0 个答案:

没有答案