开发者

WCF config files - and the famous "string content length quota (8192)" error

开发者 https://www.devze.com 2023-04-01 11:16 出处:网络
Folks, Thanks for your help with my previous WCF config file issue.Here\'s a new one. My project is a WinForms app client (.NET 4.0) that pulls data from (and saves it to) a WCF services hosted on I

Folks,

Thanks for your help with my previous WCF config file issue. Here's a new one.

My project is a WinForms app client (.NET 4.0) that pulls data from (and saves it to) a WCF services hosted on IIS 7.0. When I save a small payload, all is well. When I try to save a payload over 8192 bytes the error is:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:objEncounterType. The InnerException message was 'There was an error deserializing the object of type PsychCoverage.Common.EncounterType. 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. Line 1, position 10809.'. Please see InnerException for more details

I have confirmed that my <binding name=""> is the same as my <endpoint bindingConfiguration="">.

I've set my maxReceivedMessageSize and maxBufferPoolSize and maxBufferSize all to 10,000,000 on both my client app.config and my web.config. I tried making my <readerQuota> values very high.

In my web.config I set <httpRuntime maxRequestLength="10000000" />

This is from my client 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>

And this is from my service 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"
              bindingConfig开发者_开发技巧uration="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>

Many thanks in advance.

0

精彩评论

暂无评论...
验证码 换一张
取 消