1

重複の可能性:
WF4 / WCF の RESTful ワークフロー サービス エンドポイント

Windows Workflow Services 4.0 を REST インターフェイスで動作させようとしています。receiveRequest アクティビティと sendResponse アクティビティを持つ「Service1」という非常に単純なワークフロー サービスがあります。

デフォルトでは、WF サービスは実装されているクラスとインターフェースを自動生成しますが、WF サービスに、内部で自動生成されたインターフェースではなく、独自の REST 対応インターフェースを強制的に使用させたいと考えています。

インターフェイスは次のようになります。

[ServiceContract]
public interface IService
{
    [OperationContract]
    [WebInvoke( UriTemplate = "/Data/{item}", Method = "GET" )]
    String GetData( Int32 item );
}

ただし、このインターフェイスで動作するように XAML を構成するのは困難です。サービス コントラクト名が自分のコントラクトであることを指定するには、次のような XAML 構成が必要です。

 <Receive x:Name="__ReferenceID0" CanCreateInstance="True" DisplayName="ReceiveRequest" sap:VirtualizedContainerService.HintSize="464,90" OperationName="GetData" ServiceContractName="w:IService">

ただし、このワークフロー サービスを実行すると、次の例外が発生します。

コントラクト名 'wfService.IService' は、サービス 'Service1' によって実装されたコントラクトのリストに見つかりませんでした。

ただし、バックグラウンドで作成されるサービスは IService インターフェイスを実装していません。ワークフロー エンジンによってインスタンス化されるサービスを拡張して、独自のインターフェイスを実装する方法を知りたいです (上記で説明しました)。

ありがとう

4

1 に答える 1

3

In WF4 you cannot declare ServiceContract in code and use it. Contract is declared in XAML and WorkflowServiceHost generates endpoint from declaration.

To enable REST for for your workflowservice you have few options:

  1. Use HttpWorkflowHost from http://wf.codeplex.com/wikipage?title=WebAPIWorkflow. Limitation is that then you will have only REST.
  2. Do something similar to this: http://msdn.microsoft.com/en-us/library/aa967564.aspx Differences are: replace WorkflowFormatterBehavior instead of DataContractSerializerOperationBehavior, arguments are extracted from message contract instead of operation contract and keep in mind that you will not have client part of this example and you will have to format response according to protocol.
于 2012-08-11T16:12:07.890 に答える