方法 : IIS でワークフロー サービスをホストする
ワークフロー サービスは、サービス、Web 構成ファイル、およびいくつかのアプリケーション コードを使用して、Internet Information Services (IIS) で Windows Communication Foundation (WCF) サービスをホストする方法と同じようにインターネット インフォメーション サービス (IIS) でホストできます。IIS でホストされると、ワークフロー サービスは、自動プロセス リサイクル、処理状況の監視など、IIS 機能を活用できるようになります。
IIS でワークフロー サービスをホストするには、次の 3 つの方法があります。1 つ目は、.svc ファイル内のプリコンパイル済みのワークフロー定義を参照する方法です。2 つ目は、.xoml 拡張子の付いたワークフロー マークアップ ファイルを使用する方法です。3 つ目は、.svc ファイル内のワークフロー マークアップ ファイルを参照する方法です。
2 つ目の方法では、.xoml または .rules ファイルへの更新時に自動リサイクル機能が提供されます。3 つ目の方法は、ワークフロー マークアップをホストするためのカスタム WorkflowServiceHost の実装など、拡張シナリオで提供されます
メモ : |
---|
App_Code ディレクトリのスタンドアロンのソース ファイルにコードとしてワークフローを展開する場合、またはコード インライン ASP.NET モデルを使用してサービスを展開する場合は、次の例に示すような <コンパイル> 構成要素を使用して、Web.config ファイルのワークフロー アセンブリを参照してください。 |
<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 でサービスとしてプリコンパイル済みのワークフロー定義をホストするには
コンピュータに IIS がインストールされ、実行されていることを確認します。
ワークフロー サービスの新しい仮想ディレクトリを作成し、ASP.NET がそのディレクトリにアクセスできることを確認します。
.svc 拡張子を持つ新しいサービス ファイルを作成します。ワークフロー サービスに該当する ServiceHost ディレクティブ情報を追加して、このファイルを編集します。Factory 値は、WorkflowServiceHostFactory クラスを参照する必要があります。適切な値を持つサービス ファイルを次の例に示します。
<%@ServiceHost language=c# Debug="true" Service="Microsoft.WorkflowServices.Samples.StateMachineCalculatorService" Factory="System.ServiceModel.Activation.WorkflowServiceHostFactory" %>
手順 2. で作成した仮想ディレクトリ内に Bin サブディレクトリを作成します。
ワークフロー サービス型を含むアセンブリを Bin ディレクトリに配置します。
Web.config というファイルをアプリケーション ディレクトリ内に作成します。サービスを実行するには、Web.config ファイルがアセンブリ ファイルと同じディレクトリに存在する必要があります。
適切な構成コードをファイルに追加します。実行時に 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 でサービスとして宣言ワークフロー定義をホストするには
コンピュータに IIS がインストールされ、実行されていることを確認します。
ワークフロー サービスの新しい仮想ディレクトリを作成し、ASP.NET がそのディレクトリにアクセスできることを確認します。
ワークフロー マークアップ ファイル (拡張子 .xoml) と、同じ名前 (拡張子 .rules) のルール マークアップ ファイル (省略可能) を仮想ディレクトリに配置します。
Web.config というファイルをアプリケーション ディレクトリ内に作成します。サービスを実行するには、Web.config ファイルは、アセンブリ ファイルと同じディレクトリに存在する必要があります。
適切な構成コードをファイルに追加します。実行時に 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 ファイルを使用して、サービスとして宣言ワークフロー定義をホストするには
コンピュータに IIS がインストールされ、実行されていることを確認します。
ワークフロー サービスの新しい仮想ディレクトリを作成し、ASP.NET がそのディレクトリにアクセスできることを確認します。
ワークフロー マークアップ ファイル (拡張子 .xoml) と同じ名前 (拡張子 .rules) のルール マークアップ ファイル (省略可能) を仮想ディレクトリに配置します。
次のマークアップでサービス ディレクティブ (拡張子 .svc) を同じディレクトリに配置します。
<%@ServiceHost language=c# Debug="true" Service="Calculator.xoml" Factory="System.ServiceModel.Activation.WorkflowServiceHostFactory" %>
サービスを実行するための Web.config というファイルをアプリケーション ディレクトリに作成します。この Web.config ファイルは、サービス ファイルと同じディレクトリに配置する必要があります。
適切な構成コードをファイルに追加します。実行時に 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>
関連項目
その他の技術情報
Copyright © 2007 by Microsoft Corporation.All rights reserved.