2
votes

I have no trouble retrieving a large amount of data, but sending it back to the service displays this error.

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:response. The InnerException message was 'There was an error deserializing the object of type System.String. 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.

Here is what I have on the WCF service (server):

 <bindings>
  <basicHttpBinding>
    <binding name="BasicHTTPEndpoint" maxBufferSize="2147483647" maxBufferPoolSize="524288" 
             maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
             useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
      maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />          
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="http://192.168.1.99/Service/SerializerJsonService"
            binding="basicHttpBinding" bindingConfiguration="HandleLargeMessage"
            contract="XMLService.IXMLReader" name="BasicHTTPEndpoint" />
</client>

and the servicereferences.clientconfig:

<configuration>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_ISerializerJsonService" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://192.168.1.99/Service/SerializerJsonService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISerializerJsonService"
            contract="YelpService.ISerializerJsonService" name="BasicHttpBinding_ISerializerJsonService" />
    </client>
</system.serviceModel>

2

2 Answers

6
votes

In the server config:

  <basicHttpBinding>
    <binding name="BasicHTTPEndpoint"...

should be

<basicHttpBinding>
    <binding name="HandleLargeMessage"...

so that the endpoint will use that binding (which you specify in BindingConfiguration="HandleLargeMessage", the name attribute is naming the endpoint only here)

0
votes

I think the problem is in maxBytesPerRead="4096"