0
votes

I got the following error when i passed an entity object to a WebService

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

I tried to solve this problem by giving the below code in webconfig of Webservice,but the error still remains. Can anyone Help!!!!!

 <bindings>
      <wsHttpBinding>
        <binding name="MyService" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                    maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                   maxNameTableCharCount="2147483647" />
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="None" />
            <message clientCredentialType="UserName" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
2
provide client and server side binding. as @peer points, there is definitely a mis-match creating this error – Dhawalk
As @Dhawalk said, can you post your complete service config? Even though you may have defined larger values for the binding, there's a chance they may not be used for a couple of reasons (depending on what's in your config and what version of .NET you are on). – Tim

2 Answers

3
votes

You have to set the maximum string content length quota on the server and the client. So check your client config. If that is not working, check if you are using the right binding.

0
votes

Your server side Web config allows large strings, but you also need to modify your client side ServiceReferences.ClientConfig file to reflect that.

<configuration>
  <system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="Binding_MyService">
                <binaryMessageEncoding />
                <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="yourserviceurlhere"
            binding="wsHttpBinding" bindingConfiguration="Binding_MyService"
            contract="yourcontracthere" name="MyService" />
    </client>
</system.serviceModel>