Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased...

The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased...

Scheduled Pinned Locked Moved WCF and WF
csharpwcfhelpasp-netwpf
16 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Mark Salsbery

    Who is creating the BasicHttpBinding on the server?? Note I'm not sure that is the fix (especially since reader quotas apply to the client anyway) - I was just asking if you tried. There's a claim on this thread[^] that setting it on the server worked...

    Mark Salsbery Microsoft MVP - Visual C++ :java:

    T Offline
    T Offline
    Tesic Goran
    wrote on last edited by
    #5

    VS2010 created all config files automatically. I haven't created anything manually. I'm not sure what I should change on server side. I mean what code I should write.

    M 1 Reply Last reply
    0
    • T Tesic Goran

      VS2010 created all config files automatically. I haven't created anything manually. I'm not sure what I should change on server side. I mean what code I should write.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #6

      Tesic Goran wrote:

      VS2010 created all config files automatically

      hmm how? I don't see any endpoint configuration in your posted web.config!

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      T 1 Reply Last reply
      0
      • M Mark Salsbery

        Tesic Goran wrote:

        VS2010 created all config files automatically

        hmm how? I don't see any endpoint configuration in your posted web.config!

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        T Offline
        T Offline
        Tesic Goran
        wrote on last edited by
        #7

        That's true. And everything works fine on client side if encoded string is not too long. That's Microsoft's stuff.

        M 1 Reply Last reply
        0
        • T Tesic Goran

          That's true. And everything works fine on client side if encoded string is not too long. That's Microsoft's stuff.

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #8

          There must be some auto-generated code somewhere in the server code creating the service endpoint(s)... :)

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          T 1 Reply Last reply
          0
          • M Mark Salsbery

            There must be some auto-generated code somewhere in the server code creating the service endpoint(s)... :)

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            T Offline
            T Offline
            Tesic Goran
            wrote on last edited by
            #9

            No. You can try it in VS2010.

            M 1 Reply Last reply
            0
            • T Tesic Goran

              No. You can try it in VS2010.

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #10

              Ok....took a while to track down, but I found it documented. I've been using web.config files carried over from previous visual studio and .NET framework versions so I never noticed the configuration doesn't get added to the server web.config any more :) A Developer's Introduction to Windows Communication Foundation 4[^]...specifically the "Default Endpoints" section...

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              T 1 Reply Last reply
              0
              • M Mark Salsbery

                Ok....took a while to track down, but I found it documented. I've been using web.config files carried over from previous visual studio and .NET framework versions so I never noticed the configuration doesn't get added to the server web.config any more :) A Developer's Introduction to Windows Communication Foundation 4[^]...specifically the "Default Endpoints" section...

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                T Offline
                T Offline
                Tesic Goran
                wrote on last edited by
                #11

                Thank you for the link, but there's nothing about how I should alter my Web.config file. I've tried several things, but it doesn't work. I really don't understand Microsoft. What's the purpose of this apporach? People should concentrate to infrastructure instead of coding. In my opinion it's wrong. How to alter Web.config file?

                modified on Tuesday, May 31, 2011 11:48 PM

                1 Reply Last reply
                0
                • T Tesic Goran

                  Hi, I have VS2010 solution that consists of 2 projects: 1) ASP.NET web application with WCF service. WCF service is hosted to ASP.NET Development Server. 2) Windows Forms client application that uses WCF service. WCF service is decoding some previously encoded string and converting it to XML. The length of encoded string differs. It can be very long. What's happining? When input encoded string is very long, this exception is thrown:

                  System.ServiceModel.ProtocolException was unhandled
                  Message=The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'Decode'. 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 1, position 17956.
                  Source=mscorlib
                  StackTrace:
                  Server stack trace:
                  at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
                  at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
                  ...

                  I've read some articles and forum posts on internet and tried to increase the value of MaxStringContentLength parameter in app.config file on client side, but it didnt't help. My app.config file on client side looks as follows:

                  <?xml version="1.0" encoding="utf-8" ?>
                  <configuration>
                  <system.serviceModel>
                  <bindings>
                  <basicHttpBinding>
                  <binding name="BasicHttpBinding_IUfoDecoderService" closeTimeout="00:01:00"
                  openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                  allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
                  messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                  useDefaultWebProxy="true">
                  <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384"
                  maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                  <security mode="None">
                  <transport clientCred

                  T Offline
                  T Offline
                  Tesic Goran
                  wrote on last edited by
                  #12

                  Could someone, please, help me about this? Thank you in advance.

                  M 1 Reply Last reply
                  0
                  • T Tesic Goran

                    Hi, I have VS2010 solution that consists of 2 projects: 1) ASP.NET web application with WCF service. WCF service is hosted to ASP.NET Development Server. 2) Windows Forms client application that uses WCF service. WCF service is decoding some previously encoded string and converting it to XML. The length of encoded string differs. It can be very long. What's happining? When input encoded string is very long, this exception is thrown:

                    System.ServiceModel.ProtocolException was unhandled
                    Message=The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'Decode'. 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 1, position 17956.
                    Source=mscorlib
                    StackTrace:
                    Server stack trace:
                    at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
                    at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
                    ...

                    I've read some articles and forum posts on internet and tried to increase the value of MaxStringContentLength parameter in app.config file on client side, but it didnt't help. My app.config file on client side looks as follows:

                    <?xml version="1.0" encoding="utf-8" ?>
                    <configuration>
                    <system.serviceModel>
                    <bindings>
                    <basicHttpBinding>
                    <binding name="BasicHttpBinding_IUfoDecoderService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                    <transport clientCred

                    D Offline
                    D Offline
                    dan sh
                    wrote on last edited by
                    #13

                    You need to have similar binding configuration in the web.config of your service as well. Your services configuration should look like this:

                    <services>
                    <service name="yourService">
                    <endpoint binding="yourBinding">
                    </endpoint>
                    </service>
                    </services>

                    Endpoint should have other relevant details as well.

                    "The worst code you'll come across is code you wrote last year.", wizardzz[^]

                    T 1 Reply Last reply
                    0
                    • D dan sh

                      You need to have similar binding configuration in the web.config of your service as well. Your services configuration should look like this:

                      <services>
                      <service name="yourService">
                      <endpoint binding="yourBinding">
                      </endpoint>
                      </service>
                      </services>

                      Endpoint should have other relevant details as well.

                      "The worst code you'll come across is code you wrote last year.", wizardzz[^]

                      T Offline
                      T Offline
                      Tesic Goran
                      wrote on last edited by
                      #14

                      Thank you, but it doesn't help me. I've tried several things, but it's not working. Please, here's my app.config file on client side:

                      <?xml version="1.0" encoding="utf-8" ?>
                      <configuration>
                      <system.serviceModel>
                      <bindings>
                      <basicHttpBinding>
                      <binding name="BasicHttpBinding_IUfoDecoderService" closeTimeout="00:01:00"
                      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                      maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
                      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                      useDefaultWebProxy="true">
                      <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                      maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                      <security mode="None">
                      <transport clientCredentialType="None" proxyCredentialType="None"
                      realm="" />
                      <message clientCredentialType="UserName" algorithmSuite="Default" />
                      </security>
                      </binding>
                      </basicHttpBinding>
                      </bindings>
                      <client>
                      <endpoint address="http://localhost/UfoDecoderWebApplication/UfoDecoderService.svc"
                      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUfoDecoderService"
                      contract="ServiceReference.IUfoDecoderService" name="BasicHttpBinding_IUfoDecoderService" />
                      </client>
                      </system.serviceModel>
                      </configuration>

                      My automatically generated (by VS2010) Web.config file looks as follows:

                      <?xml version="1.0"?>

                      <!--
                      For more information on how to configure your ASP.NET application, please visit
                      http://go.microsoft.com/fwlink/?LinkId=169433
                      -->

                      <configuration>
                      <connectionStrings>
                      <add name="ApplicationServices"
                      connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
                      providerName="System.Data.SqlClient" />
                      </connectionStrings>

                      <system.web>
                      <compilation debug="true" targetFramework="4.0" />

                      <authentication mode="Forms">
                        <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
                      </authentication>
                      
                      D 1 Reply Last reply
                      0
                      • T Tesic Goran

                        Thank you, but it doesn't help me. I've tried several things, but it's not working. Please, here's my app.config file on client side:

                        <?xml version="1.0" encoding="utf-8" ?>
                        <configuration>
                        <system.serviceModel>
                        <bindings>
                        <basicHttpBinding>
                        <binding name="BasicHttpBinding_IUfoDecoderService" closeTimeout="00:01:00"
                        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                        maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                        </security>
                        </binding>
                        </basicHttpBinding>
                        </bindings>
                        <client>
                        <endpoint address="http://localhost/UfoDecoderWebApplication/UfoDecoderService.svc"
                        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUfoDecoderService"
                        contract="ServiceReference.IUfoDecoderService" name="BasicHttpBinding_IUfoDecoderService" />
                        </client>
                        </system.serviceModel>
                        </configuration>

                        My automatically generated (by VS2010) Web.config file looks as follows:

                        <?xml version="1.0"?>

                        <!--
                        For more information on how to configure your ASP.NET application, please visit
                        http://go.microsoft.com/fwlink/?LinkId=169433
                        -->

                        <configuration>
                        <connectionStrings>
                        <add name="ApplicationServices"
                        connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
                        providerName="System.Data.SqlClient" />
                        </connectionStrings>

                        <system.web>
                        <compilation debug="true" targetFramework="4.0" />

                        <authentication mode="Forms">
                          <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
                        </authentication>
                        
                        D Offline
                        D Offline
                        dan sh
                        wrote on last edited by
                        #15

                        I had shown that. You need to manually change the web.config. Add the services tag under servicemodel and rest should follow.

                        "The worst code you'll come across is code you wrote last year.", wizardzz[^]

                        1 Reply Last reply
                        0
                        • T Tesic Goran

                          Could someone, please, help me about this? Thank you in advance.

                          M Offline
                          M Offline
                          Mark Salsbery
                          wrote on last edited by
                          #16

                          I gave you a link that shows all kinds of info on customizing the configuration of the default endpoints. You said the link didn't have any info. I personally prefer to explicitly configure endpoints. I read this from the link: "Here's how it works. When the host application calls Open on the ServiceHost instance, it builds the internal service description from the application configuration file along with anything the host application may have configured explicitly and if the number of configured endpoints is still zero, it calls AddDefaultEndpoints, a new public method found on the ServiceHost class. This method adds one or more endpoints to the service description based on the service’s base addresses (in IIS scenarios, this is the .svc address). Since the method is public, you can also call it directly in custom hosting scenarios." So if you explicitly configure an endpoint it will use your configuration. There's all kinds of info on MSDN about configuring endpoints. Using web.config you can start with something like this in the system.serviceModel section (substitute your own service, namespace, and interface names):

                          <system.serviceModel>

                          <services>
                            <service name="ASPNETWebApplicationTester.Service1"
                                     behaviorConfiguration="ASPNETWebApplicationTester.Service1Behavior" >
                              <endpoint name="ASPNETWebApplicationTester.Service1Binding" 
                                        address="" 
                                        binding="basicHttpBinding" 
                                        bindingConfiguration="ASPNETWebApplicationTester.Service1Binding"
                                        contract="ASPNETWebApplicationTester.IService1">
                                <identity>
                                  <dns value="localhost" />
                                </identity>
                              </endpoint>
                              <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
                              <host>
                                <!-- \*\* No base addresses allowed when hosting on IIS 7.  Our service is at http://localhost/ASPNETWebApplicationTester/Service1.svc \*\*
                                <baseAddresses>
                                  <add baseAddress="http://localhost:55008/Design\_Time\_Addresses/ASPNETWebApplicationTester/Service1/" />
                                </baseAddresses>
                                -->
                              </host>
                            </service>
                          </services>
                          
                          <behaviors>
                            <serviceBehaviors>
                              <behavior name="ASPNETWebApplicationTester.Service1Behavior">
                                <serviceMetadata httpGetEnabled="true" />
                          
                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups