9

I've seen this problem posted a million times, but none of the solutions have worked for me...So here I go:

When calling a WCF service I get the following error:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://BlanketImportService.ServiceContracts/2011/06:request. The InnerException message was 'There was an error deserializing the object of type BlanketImport.BlanketImportRequest. 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. Line 1, position 44440.'. Please see InnerException for more details.

I have modified the readerQuotas on both the client server, AND applied the bindingConfiguration tag.

Here's the server config:

<bindings>
  <basicHttpBinding>
    <binding name="BilagImportBinding" maxBufferSize="2147483647"
      maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>

<services>
  <service name="BlanketImport">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BilagImportBinding" bindingNamespace="http://BlanketImportService.ServiceContracts/2011/06" contract="BlanketImport.IBlanketImport">
    </endpoint>
  </service>
</services>

And the client config:

  <bindings>
    <basicHttpBinding>
      <binding name="BilagImportBinding" maxBufferSize="2147483647"
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
          maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      </binding>
    </basicHttpBinding>
  </bindings>
  <client>
    <endpoint address="http://localhost/BlanketImport/BlanketService.svc"
      binding="basicHttpBinding" bindingConfiguration="BilagImportBinding" contract="BlanketServiceReference.IBlanketService"
      name="BasicHttpBinding_IBlanketService" />
  </client>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
HeineSkov
  • 449
  • 1
  • 7
  • 18
  • Is the service name just "BlanketImport", or is it under a namespace (such as BlanketImport.BlanketImport)? The value of the "name" attribute of the `` element must be the *fully-qualified-name* of the service (namespace + type name), otherwise WCF won't find it. – carlosfigueira Sep 19 '11 at 14:21
  • 1
    It is 2015 and the wcf configuration settings continue to be an enigma to most of us. – abhi Feb 17 '15 at 18:23

3 Answers3

20

Found the solution...But still very strange!

If I remove the name attribute from my binding tag and the bindingConfiguration attribute from my endpoint tag it all works. This means that the basicHttpBinding configuration is the default configuration for all basicHttpBinding endpoints

HeineSkov
  • 449
  • 1
  • 7
  • 18
2

I had the same problem whilst trying to upload files using WCF using a named binding configuration. This has to do with the changes in WCF 4.0 and "Simplified" Configuration (see MSDN)

FYI: I tried everything to solve this problem; the parameter to the service was a byte array, so we removed it and used a stream, tried changing buffered versus streaming mode and obviously the 1.5 million config options to change sizes that never got picked up with a named config.

Very strange indeed, but working with your suggestion.

Livewire
  • 21
  • 1
0

I had a similar issue where the named binding wasn't used by the endpoint. My problem was a typo in the service name. Like Livewire said, WCF 4 Simplified Configuration automatically creates a endpoint and my defined endpoint was not overwriting it.