Search code examples
c#dataservice

Entity Famework Data Service as a Windows Service how to change maxReceivedMessageSize


I'm trying to increase the maxReceivedMessageSize for my DataService. I've tried the solutions from these places:

and some other places I can't remember but I can't get it working. The DataService is not running for a Web Application but in a Windows Service. The app.config is currently looking like this:

<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" bindingConfiguration="Test"/>
    </protocolMapping>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <bindings>
      <basicHttpsBinding>
    <binding name="Test" maxBufferSize="10485760" maxReceivedMessageSize="10485760">
      <readerQuotas maxDepth="10485760" maxStringContentLength="10485760"
        maxArrayLength="10485760" maxBytesPerRead="10485760" maxNameTableCharCount="10485760" />
    </binding>
  </basicHttpsBinding>
    </bindings>
</system.serviceModel>

EDIT

I've updated the app.config content... Still can't figure out how this should be done.

EDIT

As recommended I've also set the readerQuotas without success


Solution

  • After a while we've found a solution...

    Initially we took the DataServiceHost class to host our Service which does not support these options. After using WebServiceHost to host the service it worked:

    WebServiceHost webServiceHost = new WebServiceHost(typeof(EfoDataService), new Uri[] { });
    
    //Https binding
    WebHttpBinding httpsbinding = new WebHttpBinding()
    {
        Security = { Mode = WebHttpSecurityMode.Transport },
        MaxReceivedMessageSize = 2097152,
        MaxBufferSize = 2097152,
        MaxBufferPoolSize = 2097152,
        TransferMode = TransferMode.Streamed
    };
    
    //adding https endPoint 
    webServiceHost.AddServiceEndpoint(typeof(IRequestHandler), httpsbinding, secureBaseAddress);
    

    It's a bit strange though since DataServiceHost does derive from WebServiceHost.