0

I encounter a 413 Request Entity Too Large error on my WCF 4.0.

Here's the server web.config file :

<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WCFAuthenticationBehavior">
          <serviceCredentials>
            <serviceCertificate storeLocation="LocalMachine" x509FindType="FindBySubjectName" findValue="wcfauthentication.local" />
          </serviceCredentials>
          <serviceMetadata httpGetEnabled="False" httpsGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
         <binding maxBufferSize="2147483647" 
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed" >
                <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />                   
        </binding>
        <binding name="customBasicHttpBinding" maxBufferSize="2147483647" 
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="Transport">
            <transport clientCredentialType="Certificate" />
          </security>
        </binding>
      </basicHttpBinding>
      <basicHttpsBinding>
        <binding maxBufferSize="2147483647" 
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed" >
                <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />               
        </binding>
        <binding name="customBasicHttpsBinding" maxBufferSize="2147483647" 
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed" >
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="Transport">
            <transport clientCredentialType="Certificate" />
          </security>
        </binding>
      </basicHttpsBinding>
      <wsHttpBinding>
        <binding maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647" >
          <security mode="Transport">
            <transport clientCredentialType="Certificate" />
          </security>
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647"/>
        </binding>
        <binding name="customBasicWsHttpBinding" maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647">
          <security mode="Transport">
            <transport clientCredentialType="Certificate" />
          </security>
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647"/>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="WCF_SEM_TSS.ServiceWCFAuthentication" behaviorConfiguration="WCFAuthenticationBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="https://wcfauthentication.local/ServiceWCFAuthentication.svc/"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="customBasicWsHttpBinding" 
        contract="WCF_SEM_TSS.IWCFAuthentication">
        </endpoint>
      </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
      <serviceActivations>
        <add service="WCF_SEM_TSS.ServiceWCFAuthentication" relativeAddress="ServiceWCFAuthentication.svc" />
      </serviceActivations>
    </serviceHostingEnvironment>
  </system.serviceModel>

And Here's the client web.config file :

<system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="WCFAuthenticationBehavior">
          <clientCredentials>
            <clientCertificate storeLocation="CurrentUser" x509FindType="FindBySubjectName" findValue="ClientWCFAuthentification" />
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="customWsHttpBinding" maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647">
          <security mode="Transport">
            <transport clientCredentialType="Certificate" />
          </security>
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647"/>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://wcfauthentication.local/ServiceWCFAuthentication.svc/" 
                behaviorConfiguration="WCFAuthenticationBehavior"
          binding="wsHttpBinding" bindingConfiguration="customWsHttpBinding"
          contract="WCFAuthentification.IWCFAuthentication" name="MyEndPoint" />
    </client>
  </system.serviceModel>

When I launch this portion of code :

String strEndPointAddress = "https://wcfauthentication.local/ServiceWCFAuthentication.svc";
var remoteAddress = new EndpointAddress(strEndPointAddress);
_wcf = new WCFAuthenticationClient("MyEndPoint", "https://wcfauthentication.local/ServiceWCFAuthentication.svc");

//result = _wcf.MyMethod("1", "test", LargeString.Substring(0,100), "Data1");
result = _wcf.MyMethod("1", "test", LargeString, "Data1");

I get the error. BUT, when I add the commented line on that portion, and I execute the method MyMethod with a smaller string, the second method with the large string works, the WCF can process it.

Do you have any idea why the 413 Error Request Entity Too Large disappears when I added another method before the one with the large data ?

Is it necessary to initiate the WCF connection by using a dummy method like for instance "CallMeBeforeAnyOtherCall()" ?

Thanks in advance

Thordax
  • 1,673
  • 4
  • 28
  • 54
  • please check this answer http://stackoverflow.com/questions/10122957/iis7-413-request-entity-too-large-uploadreadaheadsize – rahularyansharma Feb 04 '16 at 08:51
  • Unfortunately, I don't get more answers from your link. I already added a bindingConfiguration containing a maxReceivedMessageSize parameter with a large value, that doesn't help. – Thordax Feb 04 '16 at 09:45
  • As per above link and MSDN error code is related to max size limit crossing . I am not sure what is the size of your request . As in above mentioned link problem is with Image size through request . – rahularyansharma Feb 04 '16 at 10:40
  • The size exceeds 65 KB. But the problem is that my code works when I call another method just before the "large string" parameter method. And thus, I may have difficulties understanding the problem coming from a configuration issue. – Thordax Feb 04 '16 at 11:59

0 Answers0