다음을 통해 공유


방법: IIS에서 워크플로 서비스 호스팅

IIS(인터넷 정보 서비스)에서 WCF(Windows Communication Foundation) 서비스를 호스팅하는 것과 마찬가지로 서비스 및 웹 구성 파일과 응용 프로그램 코드를 사용하여 IIS에서 워크플로 서비스를 호스팅할 수 있습니다. IIS에서 호스팅된 워크플로 서비스는 자동 프로세스 재활용, 프로세스 상태 모니터링 등의 IIS 기능을 이용할 수 있습니다.

워크플로 서비스를 IIS에서 호스팅하는 방법은 세 가지입니다. 첫 번째 방법은 .svc 파일에서 미리 컴파일된 워크플로 정의를 참조하는 것이고, 두 번째 방법은 확장명이 .xoml인 워크플로 마크업 파일을 사용하는 것입니다. 마지막으로 세 번째 방법은 .svc 파일에서 워크플로 마크업 파일을 참조하는 것입니다.

두 번째 방법의 경우 .xoml 또는 .rules 파일을 업데이트할 때 자동 재활용 기능을 사용할 수 있습니다. 마지막 방법은 호스팅 워크플로 마크업에 대한 사용자 지정 WorkflowServiceHost를 구현하는 경우와 같은 확장 시나리오에 사용할 수 있습니다.

참고

워크플로 서비스를 App_Code 디렉터리에 있는 독립 실행형 소스 파일의 코드로 배포하거나 코드 인라인 ASP.NET 모델을 사용하여 배포하는 경우, 다음 예제와 같이 Web.config 파일에서 <compilation> 구성 요소를 통해 워크플로 어셈블리를 참조해야 합니다.

<system.web>
    <compilation>
      <assemblies>
        <add assembly="System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add assembly="System.Workflow.ComponentModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add assembly="System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </assemblies>
    </compilation>
  </system.web>

참고

IIS에서 코드 인라인 워크플로를 호스팅하는 경우 워크플로 컴파일러가 사용되지 않고 C# 컴파일러와 같은 언어별 컴파일러만 사용됩니다.

미리 컴파일된 워크플로 정의를 IIS의 서비스로 호스팅하려면

  1. IIS가 컴퓨터에 설치되어 실행되고 있는지 확인합니다.

  2. 워크플로 서비스에 대한 가상 디렉터리를 새로 만들고 ASP.NET에서 이 디렉터리에 액세스할 수 있는지 확인합니다.

  3. 확장명이 .svc인 새 서비스 파일을 만듭니다. 워크플로 서비스에 적절한 ServiceHost 지시문 정보를 추가하여 이 파일을 편집합니다. Factory 값은 WorkflowServiceHostFactory 클래스를 참조해야 합니다. 적절한 값이 포함된 서비스 파일의 예는 다음과 같습니다.

    <%@ServiceHost language=c# Debug="true" Service="Microsoft.WorkflowServices.Samples.StateMachineCalculatorService" Factory="System.ServiceModel.Activation.WorkflowServiceHostFactory" %>
    
  4. 2단계에서 만든 가상 디렉터리 안에 Bin 하위 디렉터리를 만듭니다.

  5. 워크플로 서비스 형식이 포함된 어셈블리를 Bin 디렉터리에 배치합니다.

  6. 응용 프로그램 디렉터리에 Web.config라는 파일을 만듭니다. 서비스를 실행하려면 Web.config 파일이 서비스 파일과 동일한 디렉터리에 있어야 합니다.

  7. 파일에서 적절한 구성 코드를 추가합니다. 런타임에 WCF 인프라에서는 이 정보를 사용하여 클라이언트 응용 프로그램이 통신할 수 있는 끝점을 생성합니다. StateMachineCalculatorService 샘플의 경우 구성 코드는 다음과 같습니다.

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    
      <system.serviceModel>
        <services>
          <service name="Microsoft.WorkflowServices.Samples.StateMachineCalculatorService" behaviorConfiguration="ServiceBehavior" >
            <endpoint address="" 
                      binding="customBinding"
                      bindingConfiguration="basicHttpCookieBinding"
                      contract="Microsoft.WorkflowServices.Samples.ICalculator" />
            <endpoint address="ContextOverHttp" 
                      binding="wsHttpContextBinding" 
                      contract="Microsoft.WorkflowServices.Samples.ICalculator" />
          </service>
        </services>
    
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior"  >
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
              <serviceCredentials>
                <windowsAuthentication
                    allowAnonymousLogons="false"
                    includeWindowsGroups="true" />
              </serviceCredentials>
              <!-- Comment out the following behavior to disable persistence store -->
              <workflowRuntime name="WorkflowServiceHostRuntime" validateOnCreate="true" enablePerformanceCounters="true">
                <services>
                  <add type="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                       connectionString="Data Source=localhost\sqlexpress;Initial Catalog=NetFx35Samples_ServiceWorkflowStore;Integrated Security=True;Pooling=False"
                       LoadIntervalSeconds="1" UnLoadOnIdle= "true" />
                </services>
              </workflowRuntime>
            </behavior>
          </serviceBehaviors>
        </behaviors>
    
        <bindings>
          <customBinding>
            <binding name="basicHttpCookieBinding">
              <context contextExchangeMechanism="HttpCookie" />
              <textMessageEncoding messageVersion="Soap11" />
              <httpTransport authenticationScheme="Ntlm" />
            </binding>
          </customBinding>
        </bindings>
    
      </system.serviceModel>
    
      <system.web>
        <compilation>
          <assemblies>
            <add assembly="System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          </assemblies>
        </compilation>
      </system.web>
    
    </configuration>
    

선언적 워크플로 정의를 IIS의 서비스로 호스팅하려면

  1. IIS가 컴퓨터에 설치되어 실행되고 있는지 확인합니다.

  2. 워크플로 서비스에 대한 가상 디렉터리를 새로 만들고 ASP.NET에서 이 디렉터리에 액세스할 수 있는지 확인합니다.

  3. 워크플로 마크업 파일(확장명 .xoml) 및 동일한 이름의 선택적 규칙 마크업 파일(확장명 .rules)을 가상 디렉터리에 배치합니다.

  4. 응용 프로그램 디렉터리에 Web.config라는 파일을 만듭니다. 서비스를 실행하려면 Web.config 파일이 서비스 파일과 동일한 디렉터리에 있어야 합니다.

  5. 파일에서 적절한 구성 코드를 추가합니다. 런타임에 WCF 인프라에서는 이 정보를 사용하여 클라이언트 응용 프로그램이 통신할 수 있는 끝점을 생성합니다. StateMachineCalculatorService 샘플의 경우 구성 코드는 다음과 같습니다.

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    
      <system.serviceModel>
        <services>
    <!-- Service name is workflow Name -->
          <service name="StateMachineCalculatorService" behaviorConfiguration="ServiceBehavior" >
            <endpoint address="" 
                      binding="customBinding"
                      bindingConfiguration="basicHttpCookieBinding"
                      contract="Microsoft.WorkflowServices.Samples.ICalculator" />
            <endpoint address="ContextOverHttp" 
                      binding="wsHttpContextBinding" 
                      contract="Microsoft.WorkflowServices.Samples.ICalculator" />
          </service>
        </services>
    
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior"  >
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
              <serviceCredentials>
                <windowsAuthentication
                    allowAnonymousLogons="false"
                    includeWindowsGroups="true" />
              </serviceCredentials>
              <!-- Comment out the following behavior to disable persistence store -->
              <workflowRuntime name="WorkflowServiceHostRuntime" validateOnCreate="true" enablePerformanceCounters="true">
                <services>
                  <add type="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                       connectionString="Data Source=localhost\sqlexpress;Initial Catalog=NetFx35Samples_ServiceWorkflowStore;Integrated Security=True;Pooling=False"
                       LoadIntervalSeconds="1" UnLoadOnIdle= "true" />
                </services>
              </workflowRuntime>
            </behavior>
          </serviceBehaviors>
        </behaviors>
    
        <bindings>
          <customBinding>
            <binding name="basicHttpCookieBinding">
              <context contextExchangeMechanism="HttpCookie" />
              <textMessageEncoding messageVersion="Soap11" />
              <httpTransport authenticationScheme="Ntlm" />
            </binding>
          </customBinding>
        </bindings>
    
      </system.serviceModel>
    
      <system.web>
        <compilation>
          <assemblies>
            <add assembly="System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          </assemblies>
        </compilation>
      </system.web>
    
    </configuration>
    

참고

워크플로 마크업 파일은 워크플로 서비스에 대한 기본 주소의 일부가 됩니다. 예를 들어, 기본 주소는 다음과 같을 수 있습니다.

http://servername:port/workflowmarkupfile.xoml/

.svc 파일을 사용하여 선언적 워크플로 정의를 서비스로 호스팅하려면

  1. IIS가 컴퓨터에 설치되어 실행되고 있는지 확인합니다.

  2. 워크플로 서비스에 대한 가상 디렉터리를 새로 만들고 ASP.NET에서 이 디렉터리에 액세스할 수 있는지 확인합니다.

  3. 워크플로 마크업 파일(확장명 .xoml) 및 동일한 이름의 선택적 규칙 마크업 파일(확장명 .rules)을 가상 디렉터리에 배치합니다.

  4. 다음 마크업이 포함된 서비스 지시문(확장명 .svc)을 동일한 디렉터리에 배치합니다.

    <%@ServiceHost language=c# Debug="true" Service="Calculator.xoml" Factory="System.ServiceModel.Activation.WorkflowServiceHostFactory" %>
    
  5. 응용 프로그램 디렉터리에 Web.config라는 파일을 만듭니다. 서비스를 실행하려면 Web.config 파일이 서비스 파일과 동일한 디렉터리에 있어야 합니다.

  6. 파일에서 적절한 구성 코드를 추가합니다. 런타임에 WCF 인프라에서는 이 정보를 사용하여 클라이언트 응용 프로그램이 통신할 수 있는 끝점을 생성합니다. StateMachineCalculatorService 샘플의 경우 구성 코드는 다음과 같습니다.

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    
      <system.serviceModel>
        <services>
    <!-- Service name is workflow Name -->
          <service name="StateMachineCalculatorService" behaviorConfiguration="ServiceBehavior" >
            <endpoint address="" 
                      binding="customBinding"
                      bindingConfiguration="basicHttpCookieBinding"
                      contract="Microsoft.WorkflowServices.Samples.ICalculator" />
            <endpoint address="ContextOverHttp" 
                      binding="wsHttpContextBinding" 
                      contract="Microsoft.WorkflowServices.Samples.ICalculator" />
          </service>
        </services>
    
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior"  >
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
              <serviceCredentials>
                <windowsAuthentication
                    allowAnonymousLogons="false"
                    includeWindowsGroups="true" />
              </serviceCredentials>
              <!-- Comment out the following behavior to disable persistence store -->
              <workflowRuntime name="WorkflowServiceHostRuntime" validateOnCreate="true" enablePerformanceCounters="true">
                <services>
                  <add type="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                       connectionString="Data Source=localhost\sqlexpress;Initial Catalog=NetFx35Samples_ServiceWorkflowStore;Integrated Security=True;Pooling=False"
                       LoadIntervalSeconds="1" UnLoadOnIdle= "true" />
                </services>
              </workflowRuntime>
            </behavior>
          </serviceBehaviors>
        </behaviors>
    
        <bindings>
          <customBinding>
            <binding name="basicHttpCookieBinding">
              <context contextExchangeMechanism="HttpCookie" />
              <textMessageEncoding messageVersion="Soap11" />
              <httpTransport authenticationScheme="Ntlm" />
            </binding>
          </customBinding>
        </bindings>
    
      </system.serviceModel>
    
      <system.web>
        <compilation>
          <assemblies>
            <add assembly="System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          </assemblies>
        </compilation>
      </system.web>
    
    </configuration>
    

참고 항목

기타 리소스

워크플로 서비스 및 영속 서비스 만들기

Footer image

Copyright © 2007 by Microsoft Corporation. All rights reserved.