Michael Phipps
Michael Phipps

Reputation: 1

WCF Web Service can't deserialize because of maximum string content length quota

I know that this question has been asked before, but I have read all of those and I believe that I have implemented all of their suggestions and they don't help.

Fiddler (best tool EVER!) shows that the whole of the message is getting to the server, so the client (and its app.config) is irrelevant.

The error message is:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:deal. The InnerException message was 'There was an error deserializing the object of type MYOBJECT. 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 38700.'. Please see InnerException for more details

The relevant portion of the web config:

<system.serviceModel> <bindings> <basicHttpBinding> <binding name="DefaultBinding"> <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxStringContentLength="2147483647" maxNameTableCharCount="2147483647" /> </binding> </basicHttpBinding> </bindings> <behaviors> <endpointBehaviors> <behavior name="DefaultEndpointBehavior"> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> <services> <service name="DmsIntegrationService"> <endpoint behaviorConfiguration="DefaultEndpointBehavior" binding="basicHttpBinding" bindingConfiguration="DefaultBinding" contract="MYCONTRACT" /> </service> </services> </system.serviceModel>

I understand that boosting all of these numbers to int.MaxValue is a potential DOS risk. I will lower them before I publish this.

Upvotes: 0

Views: 859

Answers (2)

Tanaji Kamble
Tanaji Kamble

Reputation: 363

try something like this

<binding name="DefaultBinding" maxBufferPoolSize="524288" maxBufferSize="524288" maxConnections="10" maxReceivedMessageSize="5242880"> <readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> </binding>

also refer to this link here

Upvotes: 1

sudhansu63
sudhansu63

Reputation: 6180

Try putting the things together in the WCF web config

<system.web>
    <httpRuntime maxRequestLength="5120000" />
</system.web>
  <system.webServer>
    <urlCompression doDynamicCompression="true" doStaticCompression="true" />
    <validation validateIntegratedModeConfiguration="false" />
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1024000000" />
      </requestFiltering>
    </security>
  </system.webServer>

Upvotes: 0

Related Questions