Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Another "The maximum string content length quota (8192) has been exceeded while reading XML data." issue with WCF and Silverlight 4

I have no trouble retrieving a large amount of data, but sending it back to the service displays this error. I've tried adding the element to both the web.config and servicereferences.clientconfig and it's not recognized in either. At one point I got a message about adding readerQuotas to bindingElementExtensions, but I can't find anything useful on how to do this. I found posts saying I had to modify the devenv.exe.config and such, but doing that hosed VS.

Edit

Here's the binding section of the web.config:

<bindings>
  <customBinding>
    <binding name="QaRiM.Web.Service1.customBinding0">
      <binaryMessageEncoding />
      <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
    </binding>
  </customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
  multipleSiteBindingsEnabled="true" />
<services>
  <service name="QaRiM.Web.Service1">
    <endpoint address="" binding="customBinding" bindingConfiguration="QaRiM.Web.Service1.customBinding0"
      contract="QaRiM.Web.Service1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

and the servicereferences.clientconfig:

<configuration>
    <system.serviceModel>
        <bindings>
            <customBinding>
                <binding name="CustomBinding_Service1">
                    <binaryMessageEncoding />
                    <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:36533/Service1.svc" binding="customBinding"
                bindingConfiguration="CustomBinding_Service1" contract="ServiceReference1.Service1"
                name="CustomBinding_Service1" />
        </client>
    </system.serviceModel>
</configuration>

Both were generated by VS.

like image 701
Jim Perry Avatar asked Oct 05 '10 19:10

Jim Perry


2 Answers

You are simply missing the configuration for the maximum string content length.

Add this to your binding attributes (client and server)

<readerQuotas maxStringContentLength="2147483647" />

Sorry, I didn't realize that this child element is located under the encoding being used when using a custom binding, it appears to bebinaryMessageEncoding in your example. If not, try the other encodings with the setting.

<bindings>
    <customBinding>
        <binding name="QaRiM.Web.Service1.customBinding0">                  
            <binaryMessageEncoding>
                <readerQuotas maxStringContentLength="2147483647"/>
            </binaryMessageEncoding>
        </binding>
    </customBinding>
</bindings>
like image 101
Jab Avatar answered Oct 15 '22 21:10

Jab


if The maximum string content length quota (8192) has been exceeded while reading XML data.” is ignoring your web.config settings EVEN after you set you can also solve the problem in your code by creating an instance of XmlDictionaryReaderQuotas and setting the MaxStringContentLength to 2147483647

then just use the instance of XmlDictionaryReaderQuotas seen here as mycreatedreaderquota

 XmlDictionaryReaderQuotas mycreatedreaderquota = new XmlDictionaryReaderQuotas();
        mycreatedreaderquota.MaxStringContentLength = 2147483647;

        XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(stream, mycreatedreaderquota);
like image 29
miles ercolani Avatar answered Oct 15 '22 22:10

miles ercolani