Thursday, 31 July 2014

Increasing request limit quota in WCF/REST Service

Customizing webHttpBinding in web.config and referencing with bindingConfiguration in endpoint element
<system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="AmmuEndPointServiceBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="AmmuServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <!-- Customizations for REST service -->
      <webHttpBinding>
        <!-- Limits set to 10 MB (specified value in bytes) -->
        <binding name="AmmuBinding" maxReceivedMessageSize="10485760" maxBufferPoolSize="10485760" maxBufferSize="10485760" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
          <readerQuotas maxDepth="32" maxStringContentLength="10485760" maxArrayLength="10485760" maxBytesPerRead="10485760" />
          <security mode="None" />
        </binding>
      </webHttpBinding>
    </bindings>
  
    <services>
      <service name="Amalay.Web.Services.AmmuService" behaviorConfiguration="AmmuServiceBehavior">
        <endpoint address="" binding="webHttpBinding" contract="Amalay.Web.Services.IAmmuService" bindingConfiguration="AmmuBinding" behaviorConfiguration="AmmuEndPointServiceBehavior" />
      </service>
    </services>

    <serviceHostingEnvironment aspNetCompatibilityEnabled= "true" multipleSiteBindingsEnabled="true"  />

  </system.serviceModel>

No comments :

Post a Comment