none
How to exeed maximum content length in wcf.? RRS feed

  • Question

  • Hi, I m working on  wpf project with wcf service.I m getting error  "The maximum string content length has been exeeded".

    For this i have changed my wpf app.config file as

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.serviceModel>
        <bindings>
          <wsHttpBinding>
            <binding name="WSHttpBinding_IDataService" closeTimeout="00:01:00"
              openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
              bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
              maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
              messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
              allowCookies="false">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              <reliableSession ordered="true" inactivityTimeout="00:10:00"
                enabled="false" />
              <security mode="Message">
                <transport clientCredentialType="Windows" proxyCredentialType="None"
                  realm="" />
                <message clientCredentialType="Windows" negotiateServiceCredential="true"
                  algorithmSuite="Default" establishSecurityContext="true" />
              </security>
            </binding>
          </wsHttpBinding>
        </bindings>
       
        <client>
          <endpoint address="http://localhost:2054/Service1.svc" binding="wsHttpBinding"
            bindingConfiguration="WSHttpBinding_IDataService" contract="ServiceReference1.IService1"
            name="WSHttpBinding_IDataService">
            <identity>
              <dns value="localhost" />
            </identity>
          </endpoint>
        
        </client>
       
      </system.serviceModel>
     
    </configuration>

    But i m still getting same error plz help me out if i also have to change wcf web.config file

    Thanks

    Tuesday, June 3, 2014 10:22 AM

Answers

  • Hi,

    By default the WCF service will use the basicHttpBinding, then it you want to use the wsHttpBinding, you will need to add the following endpoint:

    <endpoint address="" binding="wsHttpBinding"
             bindingConfiguration="wsHttpBindingSettings" contract="....IService1">
             

    Also you have used the following in the client side:

            <security mode="Message">
                <transport clientCredentialType="Windows" proxyCredentialType="None"
                   realm="" />
                 <message clientCredentialType="Windows" negotiateServiceCredential="true"
                   algorithmSuite="Default" establishSecurityContext="true" />
               </security>


    Then if you want to do the authentication, you should also use it in the service side.


    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 4, 2014 6:22 AM
    Moderator

All replies

  • Your question is not WPF related at all but you also need to extended the maxStringContentLength of the readerQuotas in the binding element for my service, i.e. in the the web.config file for the service it is hosted in IIS.

    Post your service's web.config for further help.

    Tuesday, June 3, 2014 10:37 AM
  • Hi , this is my web config file

    <?xml version="1.0"?>
    <configuration>

      <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <system.serviceModel>
       
          <bindings>
            <wsHttpBinding>
              <binding name="wsHttpBindingSettings" maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                  maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              </binding>
            </wsHttpBinding>
          </bindings>
       
          <behaviors>
            <serviceBehaviors>
              <behavior name="DataServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceThrottling maxConcurrentSessions="102222222" maxConcurrentInstances="2147483647" />
              </behavior>
            </serviceBehaviors>
          </behaviors>
        </system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
     
     <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>
     
    </configuration>

    Tuesday, June 3, 2014 10:43 AM
  • Hi , this is my web config file

    <?xml version="1.0"?>
    <configuration>

      <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <system.serviceModel>
       
          <bindings>
            <wsHttpBinding>
              <binding name="wsHttpBindingSettings" maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                  maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              </binding>
            </wsHttpBinding>
          </bindings>
       
          <behaviors>
            <serviceBehaviors>
              <behavior name="DataServiceBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceThrottling maxConcurrentSessions="102222222" maxConcurrentInstances="2147483647" />
              </behavior>
            </serviceBehaviors>
          </behaviors>
        </system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
     
     <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>
     
    </configuration>


    Remove the name from (name="wsHttpBindingSettings") the binding element:

    <wsHttpBinding>
               <binding maxReceivedMessageSize="2147483647">
                 <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                   maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
               </binding>
             </wsHttpBinding>

    If you give a particular name to the binding, the bindingConfiguration specified in the service endpoint must match with it.

    Tuesday, June 3, 2014 10:48 AM
  • Hi,   Thanks for reply but whenever i have added my service in wpf app getting error "not able to download metadata from this address"
    Tuesday, June 3, 2014 11:01 AM
  • Hi,

    By default the WCF service will use the basicHttpBinding, then it you want to use the wsHttpBinding, you will need to add the following endpoint:

    <endpoint address="" binding="wsHttpBinding"
             bindingConfiguration="wsHttpBindingSettings" contract="....IService1">
             

    Also you have used the following in the client side:

            <security mode="Message">
                <transport clientCredentialType="Windows" proxyCredentialType="None"
                   realm="" />
                 <message clientCredentialType="Windows" negotiateServiceCredential="true"
                   algorithmSuite="Default" establishSecurityContext="true" />
               </security>


    Then if you want to do the authentication, you should also use it in the service side.


    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 4, 2014 6:22 AM
    Moderator