views:

1511

answers:

1

My web method kept faulting and investigations eventually revealed the following:

The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'SendFirmware'. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.

The array in question is a byte[] containing the firmware image mentioned in the method name. This is why it has so many elements. OK, marvellous, now I know what's wrong, and if I were explicitly managing the XML it wouldn't be a problem. But I'm not, it's all implicit.

How does one set this in the config file for a web service?

+4  A: 

This can be set in the web.config file in the section:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding" maxBufferSize="2147483647" 
               maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="8388608" 
               maxArrayLength="16384" maxBytesPerRead="4096" 
               maxNameTableCharCount="16384" />
        </binding>
      </basicHttpBinding>
    </bindings>
</system.serviceModel>
Robert Wagner