Skip to content

Configuration Example

Overview

On this page ,we provide example configuration in case of your IIS use anonymous authentication. The example includes sample configuration of system.serviceModel section both on the service side and client side.

Configurations

Case1: IIS use anonymous authentication

Description

Here is an example configuration in case of your IIS use anonymous authentication.
You can use the template and modify highlighted lines to fit your environment.

Configuration example

Service configuration

Service configuration (web.config)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
    <section name="cdbcService" type="CdbcServiceUtils.Config.CdbcConfigurationSectionHandler, CdbcServiceUtils" />
  </configSections>
  <system.web>
    <compilation targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Windows" />
    <customErrors  mode="On" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="5798464">
        </binding>
      </basicHttpBinding>
      <basicHttpsBinding>
        <binding maxReceivedMessageSize="5798464">
        </binding>
      </basicHttpsBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/>
          <serviceDebug includeExceptionDetailInFaults="false" httpHelpPageEnabled="false" httpsHelpPageEnabled="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <directoryBrowse enabled="false" />
  </system.webServer>

  <cdbcService>
    <userAuthentication authMethod="UserPsk">
      <authenticatedUsers>
        <add userId="****" userPsk="" comment="" />
      </authenticatedUsers>
    </userAuthentication>
    <clientApplicationAuthentication authMethod="ApplicationPsk">
      <authenticatedApplications>
        <add applicationId="****" applicationPsk="" comment="" />
      </authenticatedApplications>
    </clientApplicationAuthentication>
        <idps enabled="true" 
          accessBlockApplicationFailureCount="3"           
          accessBlockUserFailureCount="4" 
          accessBlockIpAdressFailureCount="5" 
          accessBlockSeconds="5" 
          failureResetSeconds="600"/>
    <connectionStrings>
      <add name="****" connectionString="" providerName=""/>
    </connectionStrings>
  </cdbcService>
  <log4net>
    <appender name="RollingLogFileAppenderSystem" type="log4net.Appender.RollingFileAppender,log4net">
      <param name="File" value="C:\logs\cdbc\CdbcClient." />
      <param name="AppendToFile" value="true" />
      <param name="MaxSizeRollBackups" value="10" />
      <param name="MaximumFileSize" value="5MB" />
      <param name="RollingStyle" value="date" />
      <param name="StaticLogFileName" value="false" />
      <param name="DatePattern" value="&quot;.&quot;yyyyMMdd&quot;.log&quot;" />
      <layout type="log4net.Layout.PatternLayout,log4net">
        <param name="ConversionPattern" value="%d [%t] %5p (%C:%M:%L) - %m%n" />
      </layout>
    </appender>
    <appender name="RollingLogFileAppenderAudit" type="log4net.Appender.RollingFileAppender,log4net">
      <param name="File" value="C:\logs\cdbc\CdbcAudit." />
      <param name="AppendToFile" value="true" />
      <param name="MaxSizeRollBackups" value="10" />
      <param name="MaximumFileSize" value="5MB" />
      <param name="RollingStyle" value="date" />
      <param name="StaticLogFileName" value="false" />
      <param name="DatePattern" value="&quot;.&quot;yyyyMMdd&quot;.log&quot;" />
      <layout type="log4net.Layout.PatternLayout,log4net">
        <param name="ConversionPattern" value="%d [%t] %5p (%C:%M:%L) - %m%n" />
      </layout>
    </appender>
    <logger name="audit">
      <appender-ref ref="RollingLogFileAppenderAudit" />
    </logger>
    <logger name="system">
      <appender-ref ref="RollingLogFileAppenderSystem" />
    </logger>
  </log4net>
</configuration>

Client configuration

https case: Client configuration in case of using https (app.config)

Add following setting into you app.config

  <system.serviceModel>
        <bindings>
          <basicHttpsBinding>
            <binding name="CdbcService" maxReceivedMessageSize="5798464" />
          </basicHttpsBinding>
        </bindings>
        <client>
          <endpoint address="Your service url. e.g  https://********/CdbcService/CdbcService.svc" 
                    binding="basicHttpsBinding" 
                    bindingConfiguration="CdbcService"
                    contract="CdbcService.ICdbcService" 
                    name="CdbcService.ICdbcService"  />
        </client>
  </system.serviceModel>

http case: Client configuration in case of using http (app.config)

Add following setting into you app.config

  <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="CdbcService" maxReceivedMessageSize="5798464" />
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="Your service url. e.g  http://********/CdbcService/CdbcService.svc" 
                    binding="basicHttpBinding" 
                    bindingConfiguration="CdbcService"
                    contract="CdbcService.ICdbcService" 
                    name="CdbcService.ICdbcService"  />
        </client>
  </system.serviceModel>