0

I making simple WCF service Server Side running on iis Client WinForms.

When I trying to send big string to server i have following exception:

The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'CreateFolder'. 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 147, position 78.

client app.config:

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService1" maxReceivedMessageSize="10000000" >
          <readerQuotas maxDepth="32" maxStringContentLength="10000000"   maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://192.168.15.72:7777/Service1.svc" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
        name="BasicHttpBinding_IService1" />
    </client>
  </system.serviceModel>
</configuration>

Server Web config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService1" maxReceivedMessageSize="10000000"
        maxBufferSize="10000000" >
          <readerQuotas maxDepth="32" maxStringContentLength="10000000"   maxArrayLength="16384"
                     maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="WCFService">
        <endpoint address="" binding="basicHttpBinding"
          bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
          name="BasicHttpBinding_IService1">
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <appSettings>
    <add key="PathToSafe" value="D:\Temp"/>
  </appSettings>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

When i run server on localhost iis it works great. Any ideas how to solve this?

Yury
  • 57
  • 13
  • 2
    Duplicate possible see this link here, http://stackoverflow.com/questions/6600057/the-maximum-string-content-length-quota-8192-has-been-exceeded-while-reading-x – Bearcat9425 Jul 10 '13 at 13:03
  • Be aware that if you don't assign that binding definition to the endpoint (via the `bindingConfiguration` attribute on the `endpoint` element) the changes won't take effect. The default values for the endpoint's specified binding will be used. – Tim Jul 10 '13 at 22:10

2 Answers2

2

The binding applies to both client and service. You modified the client side correctly, but you need to do it on the server side as well.

The client sends request to server - server is doing deserialization, and your error occurs while deserializing. Everything points out that you didn't update server-side config for binding (web.config)

veljkoz
  • 8,384
  • 8
  • 55
  • 91
  • Could you tell how exactly config this? I have no idea how to do this – Yury Jul 11 '13 at 05:35
  • Locate the web.config file. Find the "bindings\basicHttpBinding" section, and copy paste the "binding" node from client over the matching one found at the service. If you're still not sure - copy/paste the web.config and update your post and I'll post an answer how it should look like... – veljkoz Jul 11 '13 at 09:44
0

check your maxReceiveMessageSize and maxBufferSize

<binding name="BasicHttpBinding_IService1"
             maxReceivedMessageSize="10000000"
             maxBufferSize="10000000">
</binding>

they should be sufficiently large to allow your larger strings + what else is in your message

Batavia
  • 2,497
  • 14
  • 16