Issue with maxStringContentLength on WCF

237 views Asked by At

I have inherited a WCF web service which is running ASP.Net 2 on IIS 7.

However, we have a problem when posting large amounts of data, it produces an error 400 Bad Request.

I've added element, as a trace is producing the following error

"There was an error deserializing the object of type CIX.API.Contracts.PostMessage. 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 51, position 322."

I've included the whole system.serviceModel below - can anyone spot anything that's amiss? I've been trying to fix this for some time, but I've been unable to and any help would be very much appreciated.

<diagnostics>
    <messageLogging logMessagesAtTransportLevel="true" logMessagesAtServiceLevel="false" logMalformedMessages="true" logEntireMessage="true" maxSizeOfMessageToLog="65535000" maxMessagesToLog="500" />
</diagnostics>
<extensions>
  <behaviorExtensions>
    <add name="restHttpBehavior" type="CIX.API.Behaviors.ErrorHandling.RestBehaviorExtension, CIX.API, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
  </behaviorExtensions>
  <bindingElementExtensions>
    <add name="secureCIXChannel" type="CIX.API.Channels.SecureCIX.SecureCIXBindingExtension, CIX.API, Version=2.0.0.0, Culture=neutral" />
    <add name="hlRestChannel" type="CIX.API.Channels.HLRest.HLBindingExtension, CIX.API" />
  </bindingElementExtensions>
</extensions>
<services>
  <service behaviorConfiguration="CIX.API.ServiceBehavior" name="CIX.API.CIX">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/API/" />
      </baseAddresses>
    </host>
    <endpoint contract="CIX.API.ICIX" address="" binding="customBinding" bindingConfiguration="CIXBinding" behaviorConfiguration="CIX.API.CIXBehavior" />
  </service>
</services>
<bindings>
  <customBinding>
    <binding name="CIXBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
      <secureCIXChannel />
      <webMessageEncoding>
        <readerQuotas MaxStringContentLength="2147483647" />
      </webMessageEncoding>       
      <httpTransport manualAddressing="true" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
    </binding>  
  </customBinding>
</bindings>
<behaviors>
  <endpointBehaviors>
    <behavior name="CIX.API.CIXBehavior">
      <dataContractSerializer maxItemsInObjectGraph="200000" />
      <!--<webHttp />-->
      <restHttpBehavior />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="CIX.API.ServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
    <behavior name="CIX.Web.CIXBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>

Leslie

1

There are 1 answers

2
Shreyash Maheshwari On

Also try adding maxArrayLength="2147483647" maxBytesPerRead="2147483647" to the readerquota.