Question

I have 2 WCF service working together. One is Class Library and another one in webservice.

Its working fine until now. But if i try to send large amount of data it throw me 413 error...

An exception was thrown: The remote server returned an error: (413) Request Entity Too Large.

Below is web.config file-

For Class Library-

    <add key="SMTP" value ="dummy"/>
    <add key="BookingEmailFrom" value ="dummy"/>
    <add key="BookingEmailToWBD" value ="dummy"/>

  </appSettings>
  <connectionStrings/>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <!--
        The <authentication> section enables configuration 
        of the security authentication mode used by 
        ASP.NET to identify an incoming user. 
    -->
    <authentication mode="Windows"/>
    <!--
        The <customErrors> section enables configuration 
        of what to do if/when an unhandled error occurs 
        during the execution of a request. Specifically, 
        it enables developers to configure html error pages 
        to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
         <error statusCode="403" redirect="NoAccess.htm" />
         <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
    -->
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
  <!-- 
      The system.webServer section is required for running ASP.NET AJAX under Internet
      Information Services 7.0.  It is not necessary for previous version of IIS.
  -->
  <system.serviceModel>
    <services>
      <service name="JSONWebService.Service1" behaviorConfiguration="JSONWebService.Service1Behavior">
        <endpoint address="../Service1.svc" binding="webHttpBinding" contract="JSONWebService.IService1"

behaviorConfiguration="webBehaviour"/>

For web service client-

<?xml version="1.0"?>
<configuration>
  <!-- 
      Note: As an alternative to hand editing this file you can use the 
      web admin tool to configure settings for your application. Use
      the Website->Asp.Net Configuration option in Visual Studio.
      A full list of settings and comments can be found in 
      machine.config.comments usually located in 
      \Windows\Microsoft.Net\Framework\vx.x\Config 
  -->
  <configSections>

  </configSections>
  <appSettings>
    <add key="ConnectionString" value="Server=dummy;uid=sa;pwd=dummy;database=dummy"/>

---------------------- --> section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. --> section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
         <error statusCode="403" redirect="NoAccess.htm" />
         <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
    -->
    <pages>
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral,

PublicKeyToken=31BF3856AD364E35"/>

          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <endpoint address="basic" binding="webHttpBinding" contract="JSONWebService.IService1"

behaviorConfiguration="webBehaviour"/>

      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior" >
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before

deployment -->

    </bindings>


  </system.serviceModel>



</configuration>

Any help would be really appreciated.

Thanks

No correct solution

OTHER TIPS

You are encountering a WCF default limit on the message size. To raise the limit, use the maxReceivedMessageSize attribute in your web.config file (server side).

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding maxReceivedMessageSize="10000000">
    </basicHttpBinding>
  </bindings>
</system.serviceModel>

This is probably really late, but for anyone else that is also stuck.

The initial problem is solved by what BilalAlam described (increase the maxRecievedMessageSize) but your issue is the bindings need to be tied to the endpoint via the bindingConfiguration in the endpoint and the name in the binding.

Example

<bindings>
  <webHttpBinding>
    <binding maxReceivedMessageSize="2147483647" name="NAMETOTIEENDPOINT">
      <readerQuotas maxStringContentLength="2000000"/>
    </binding>
  </webHttpBinding>
</bindings>
<services>
  <service>
    <endpoint address="basic" bindingConfiguration="NAMETOTIEENDPOINT" binding="webHttpBinding" contract="JSONWebService.IService1"  />
  </service>
</services>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top