.netwcfsslhttpsmaxreceivedmessagesize

WCF maxReceivedMessageSize not working over HTTPS


I'm trying to receive large XML messages using a WCF service encriptes with SSL over HTTPS. My application is built over .NET Framework 4.5 and is deployed on a IIS 8.5 server.

Using the following Web.Config configuration I'm able to receive the large XML over HTTP but it presents some problems over HTTPS. (HTTPS communications is already working fine, with a self signed certificate and all).

   <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="5242880" maxBufferSize="5242880"/>
      </basicHttpBinding>

      <basicHttpsBinding>
         <binding maxReceivedMessageSize="5242880" maxBufferSize="5242880"/>
      </basicHttpsBinding>
    </bindings>

    <behaviors>   
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>

PErforming some tests using SoapUI, the large file is only sent over HTTPS when the definitions are updated (even without any changes in the Web.Config file).

When an external system (TIBO/PI from SAP) calls our service it simplr doesen't work, presenting the following error message:

HTTP/1.1 413 Request Entity Too Large Cache-Control: private Server: Microsoft-IIS/8.0 X-AspNet-Version: 4.0.30319 X-SourceFiles: =?UTF-8?B?QzpcVkFMRVxDb2RpZ28tYnJhbmNoLW9uZGExLW9uZGEyLW1lcmdlXFN1cHBsaWVyRmluYW‌​5jZS5XZWJTZXJ2aWNlc1xDb250cmF0b3Muc3Zj?= X-Powered-By: ASP.NET Date: Thu, 09 Apr 2015 22:28:41 GMT Content-Length: 0


Solution

  • Try this binding (I explicitly specified the name of binding so use it in service configuration)

    <basicHttpBinding>
        <binding maxReceivedMessageSize="10485760">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="10485760" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <security mode="None"/>
        </binding>
    </basicHttpBinding>
    <basicHttpsBinding>
        <binding maxReceivedMessageSize="10485760">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="10485760" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <security mode="None"/>
        </binding>
    </basicHttpsBinding>
    

    If it does not work try to add

    <system.webServer>
        <serverRuntime uploadReadAheadSize="2147483646"/>
    </system.webServer>
    

    to you configuration. Hope it helps.