Configuring the Web Host for a DCS Service

To enable Internet Information Services (IIS) to host your DCS service, and enable your service to use the correct configuration to communicate with the Discovery Service, you must add a web.config file to the Web application folder hosted in IIS. The web.config file provides information to configure the following features of a DCS service:

  • Diagnostic flags for tracing and monitoring the service
  • System diagnostics configuration
  • DCS Service Factory configuration
  • DCS Channel Factory configuration
  • Service model configuration
  • Web configuration
  • Workflow host configuration

Configuring Diagnostic Flags

A DCS service supports the following flags that enable and disable built-in diagnostics and monitoring functionality:

  • DCS performance counters
  • Event logging
  • Windows Management Instrumentation (WMI) events
  • Trace messages
  • Debug messages

You can configure the AppSettings section to enable and disable these flags.The following example shows the <appSettings> section from the default configuration file.

<appSettings>
    <!--  activator connection strings -->
    <add key="performanceCountersEnabled" value="false"/>
    <add key="eventLoggingEnabled" value="true"/>
    <add key="wmiEnabled" value="false"/>
    <add key="traceEnabled" value="false"/>
    <add key="debugEnabled" value="false"/>
</appSettings>

Configuring System.Diagnostics

DCS supports system.diagnostics tracing for logging events that occur when a service runs. DCS provides two event sources:

  • CIS. This records information about the progress of request and response messages through the DCS software infrastructure. For example, it captures milestone events such as starting and stopping a workflow instance and using a filter to show how a request is directed to a specific task instance.
  • Microsoft.ConnectedIndustry.ServiceModel. This records information about the connectivity between a client application and a DCS service. For example, it captures events that identify the physical endpoint used for a service and the transport and binding that a client application has connected through. It also captures information about the discovery and metadata exchange processes that occur when a client connects to a service.

You can send trace data to any listener class that inherits from the System.Diagnostics.TraceListener class. The following example shows how to configure the CIS and Microsoft.ConnectedIndustryServices.ServiceModel event sources to log events to the application event log.

<system.diagnostics>
  <sources>
    <source name="CIS" switchValue="Error, Critical">
      <listeners>
        <add name="EventLog"/>
      </listeners>
    </source>
    <source name="Microsoft.ConnectedIndustry.ServiceModel" switchValue="Error, Critical">
      <listeners>
        <add name="EventLog"/>
      </listeners>
    </source>
  </sources>
  <sharedListeners>
    <add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="DCS Runtime"/>
  </sharedListeners>
</system.diagnostics>

Configuring the DCS Service Factory

The DCS Service Factory configures the base address of the service and specifies the binding configurations for the service. You configure the DCS Service Factory by using the <serviceFactory> element of the custom <cis.serviceModel> section of the configuration file. To use the <serviceFactory> configuration settings, you must import the Microsoft.ConnectedIndustry.ServiceModel.Configuration.ChannelFactorySection class as a member of the <cis.serviceModel> section group.

You use the <defaultServiceConfiguration> element of the <serviceFactory> configuration settings to specify the endpoints for the service. Optionally, you can specify a Windows Communication Foundation (WCF) serviceBehavior that you can define by using the <system.ServiceModel> section of the configuration file. For more information, see <behaviors>.

You use the <defaultEndpoint> child element to configure the bindings of the default endpoint exposed by the service. Client applications locate a DCS service by using the Discovery Service, and the bindings exposed by the <defaultEndpoint> element are propagated to the client application and are used to configure the client channel. An operation in a DCS service that implements the client-initiated request/response or one-way messaging patterns uses the <defaultSimplexBinding> binding. An operation that can initiate messaging with a client application by using a callback contract uses the <defaultDuplexBinding> binding.

Note

A service can expose multiple endpoints. The <defaultEndpoint> element defines the binding that a client application will use to communicate with the service by default. A client application can implement an endpoint selector that picks an alternative endpoint for a service if a service provides multiple endpoints. For more information, see Building a Custom Endpoint Selector.

You can configure a DCS service to use any of the standard WCF binding configurations, or you can define a custom binding. DCS provides the extendedHttpBinding custom binding that supports the custom protocol channels implemented by DCS. For example, it supports response caching, DCS security, and the other policies provided with DCS. You can also compose a custom binding by using the individual binding elements included with DCS. For more information, see Building a Custom Binding with DCS Binding Elements.

The following sample shows an example DCS Service Factory configuration.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="cis.serviceModel" type="Microsoft.ConnectedIndustry.ServiceModel.Application.Configuration.ServiceModelSectionGroup, Microsoft.ConnectedIndustry.ServiceModel.Application, version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <section name="channelFactory" type="Microsoft.ConnectedIndustry.ServiceModel.Configuration.ChannelFactorySection,Microsoft.ConnectedIndustry.ServiceModel,Version=1.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      ...
    </sectionGroup>
  </configSections>
  ...

  <cis.serviceModel>
    <serviceFactory>
      <httpBaseAddress dnsAlias="CCF2009SERVER"/>
      <defaultServiceConfiguration serviceBehavior="DCSBehavior">
        <defaultEndpoint behaviorConfiguration="enableTracing">
          <defaultSimplexBinding binding="customBinding" bindingConfiguration="customPolicyBinding"/>
          <defaultDuplexBinding binding="extendedHttpBinding" bindingConfiguration="duplex"/>
        </defaultEndpoint>
      </defaultServiceConfiguration>
    </serviceFactory>
    ...
  </cis.serviceModel>
  ...
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DCSBehavior">
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="enableTracing">
          <tracing/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <extendedHttpBinding>
        <binding name="simplex"/>
        <binding name="duplex" isComposite="true" />
      </extendedHttpBinding>
      ...
    </bindings>
    ...
    <extensions>
      <bindingExtensions>
        <add name="extendedHttpBinding" type="Microsoft.ConnectedIndustry.ServiceModel.Application.Bindings.ExtendedHttpBindingCollectionElement, Microsoft.ConnectedIndustry.ServiceModel.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </bindingExtensions>
      ...
      <behaviorExtensions>
        <add name="tracing" type="Microsoft.ConnectedIndustry.ServiceModel.Application.Instrumentation.TracingBehaviorExtension, Microsoft.ConnectedIndustry.ServiceModel.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </behaviorExtensions>
    </extensions>
  </system.serviceModel>
  ...
</configuration>

Configuring the DCS Channel Factory

A DCS service can also act as a client, and it might need to be able to send requests to other services. You use the <channelFactory> element of the <cis.ServiceModel> section to configure the settings that enable a service to use the Discovery Service and connect to other services. For more information, see Configuring a DCS Client Application.

Configuring the Service Model

A DCS service is an extended WCF service. You use the WCF <system.serviceModel> to configure bindings for endpoints, define service and endpoint behaviors, and include extensions. For more information, see <system.serviceModel>.

Configuring System.Web Settings

You can configure the Web settings for a DCS Web service hosted by using IIS by using the <system.web> section. For more information, see system.web Element.

A DCS service requires the assemblies Microsoft.ConnectedIndustry.ProcessExecution.Configuration.Services, Microsoft.ConnectedIndustry.ServiceModel, and Microsoft.ConnectedIndustry.ServiceModel.Application to compile and run under IIS. You should add these assemblies to the <assemblies> section, as shown in the following code example.

<system.web>
  <compilation debug="true">
    <assemblies>
      <add assembly="Microsoft.ConnectedIndustry.ProcessExecution.Configuration.Services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add assembly="Microsoft.ConnectedIndustry.ServiceModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add assembly="Microsoft.ConnectedIndustry.ServiceModel.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </assemblies>
  </compilation>
</system.web>

Configuring the Workflow Host

The default model used by DCS to implement business operations is based on Windows Workflow Foundation workflows. A DCS service uses the by the Microsoft.ConnectedIndustry.ProcessExecution.WorkflowHost.ExtendedSqlWorkflowPersistenceService class to run workflows. This is a customized version of the Windows Workflow Foundation System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService class. It represents a persistence service that uses a SQL Server database to store workflow state information. The extended class that is provided with DCS can also persist DCS service metadata and context information. You can replace this customized workflow host with your own implementation if your organization has different requirements.

You configure the workflow host by using the <WorkflowHost> section of the configuration file. You specify the class that implements the workflow host environment and any parameters that the workflow host requires. The DCS SqlWorkflowPersistenService class requires you to provide a connection string for the SQL Server database that it uses for storing dehydrated workflows. The following example shows the default configuration.

<WorkflowHost Name="WorkflowHost">
  <CommonParameters>
    <add name="ConnectionString" value="Database=WorkflowPersistenceStore;Server=CCFSQL;Integrated Security=Yes;"/>
  </CommonParameters>
  <Services>
    <add type="Microsoft.ConnectedIndustry.ProcessExecution.WorkflowHost.ExtendedSqlWorkflowPersistenceService, Microsoft.ConnectedIndustry.ProcessExecution.WorkflowHost, version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" UnloadOnIdle="true" PersistOnIdle="true" LoadIntervalSeconds="20" OwnershipTimeoutSeconds="360" ConnectionString="Database=WorkflowPersistenceStore;Server=CCFSQL;Integrated Security=Yes;" ApplicationId="078E8A7E-5373-4C00-9C87-53D3E5C18873" HostProxyUrl="http://CCF2009SERVER/AppManagementService/WorkflowManagementService.svc"/>
  </Services>
</WorkflowHost>

Sample DCS Web.config File

DCS provides a Web.config file to configure the Application Management Service as part of the default installation, which you can use as a template configuration file for your service. You can extend the file to include custom configuration settings and modify existing settings as necessary. You can find this file in the folder C:\Program Files\Microsoft CIS\DCS\V1.0\Services\ApplicationManagementServices.

See Also

Configuring and Monitoring DCS Services

<behaviors>

Building a Custom Endpoint Selector

Building a Custom Binding with DCS Binding Elements

Configuring a DCS Client Application

<system.serviceModel>

system.web Element