Link to home
Start Free TrialLog in
Avatar of tryokane
tryokane

asked on

How to overcome the problem of max string content length in WCF services?

I have a requirement to build a wcf service which accepts large xml data as input and do the process of the bill and return xml with the processed data back to the called client.But when i am doing this thing i am getting a problem like the above.Can anyone suggest me what to do?My web.config and app.config files are below for reference.
The web.config file in the service:
 
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <system.serviceModel>
    <services>
      <!-- Before deployment, you should remove the returnFaults behavior configuration to avoid disclosing information in exception messages -->
      <service behaviorConfiguration="mexBehavior" name="MyService">
        <endpoint address="" binding="wsHttpBinding" contract="IMyService"/>
               </service>
    </services>
         <bindings>
        <wsHttpBinding>
          <binding name="NewBinding0" closeTimeout="00:10:00" openTimeout="00:10:00"
                      sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
                      messageEncoding="Text">
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                          maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          </binding>
        </wsHttpBinding>
      </bindings>
 
       <behaviors>
        <serviceBehaviors>
        <behavior name="mexBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.web>
    <compilation debug="true">
      <assemblies>
        <add assembly="ILOG.Rules, Version=3.0.2020.2, Culture=neutral, PublicKeyToken=249B1F6759E7EF16"/>
        <add assembly="ILOG.Rules.RuleEngine, Version=3.0.2020.3, Culture=neutral, PublicKeyToken=249B1F6759E7EF16"/>
        <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="SMDiagnostics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.IdentityModel.Selectors, Version=3.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="Microsoft.Transactions.Bridge, Version=3.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.RegularExpressions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
      </assemblies>
    </compilation>
  </system.web>
</configuration>
 
The app.config file in the client console application:
 
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <httpRuntime maxRequestLength="2147483647" />
  </system.web>
    <system.serviceModel>
      <bindings>
        <wsHttpBinding>
          <binding name="WSHttpBinding_IMyService" closeTimeout="00:01:00"
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10: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://l11-it-154a.sg.rmg.dom/ramesh/engineprocessor/WCFService/Service.svc"
                binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService"
                contract="ConsoleApplication1.localhost.IMyService" name="WSHttpBinding_IMyService">
                <identity>
                    <userPrincipalName value="L11-IT-154A\ASPNET" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

Open in new window

Avatar of Aaron Jabamani
Aaron Jabamani
Flag of United Kingdom of Great Britain and Northern Ireland image

Can we see the full error message plz.
Avatar of tryokane
tryokane

ASKER

the formatter threw an exception while trying to deserialize the message:Error in deserializing body of request message for operation 'CalculateMediSave'.The maximum string content length quota (8192) has been exceeded while reading XML data.This quota may be increased by changing the MaxStringContentLenght property on the XmldictionaryReaderQuotas object used when creating the XML reader Line 273,position 35.
Add also below and try.

<configuration>
  <system.web>
  <httpRuntime maxRequestLength="2147483647"
      </system.web>
</configuration>
I tried the above one but still getting the same error.
Anyone who can answer this one?
ASKER CERTIFIED SOLUTION
Avatar of johanekwall
johanekwall
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the suggestions!