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