This topic applies to Windows Workflow Foundation 4 (WF4).

This sample demonstrates how the messaging activities, Receive and SendReply can be used to expose an existing custom activity as an operation in a workflow service. This sample includes a new custom activity called an OperationScope. It is intended to ease the development of a workflow service by allowing users to author the body of their operations separately as custom activities and then easily exposing them as service operations using the OperationScope activity. For example, a custom Add activity that takes two in arguments and returns one out argument could be exposed as an Add operation on the workflow service by dropping it into an OperationScope.

The scope works by inspecting the activity provided as its body. Any unbound in arguments are assumed to be inputs from the incoming message. All out arguments, regardless of whether they are bound, are assumed to be outputs in the subsequent reply message. The exposed operation’s name is taken from the display name of the OperationScope activity. The end result is that the body activity is wrapped in a Receive and SendReply with the parameters from the messages bound to the arguments of the activity.

This sample exposes a workflow service using HTTP endpoints. To run, proper URL ACLs must be added. For more information, see Configuring HTTP and HTTPS. Executing the following command at an elevated prompt adds the appropriate ACLs (ensure that your Domain and Username are substituted for %DOMAIN%\%UserName%).

netsh http add urlacl url=http://+:8000/ user=%DOMAIN%\%UserName%

To run the sample

  1. Open the OperationScope.sln solution in Visual Studio 2010.

  2. Set multiple start-up projects by right-clicking the solution in Solution Explorer and selecting Set Startup Projects. Add Scenario and Scenario_Client (in that order) as multiple start-up projects.

  3. Press CTRL+SHIFT+B to build the solution.

    Ee662961.Warning(en-us,VS.100).gif Caution:
    This step is required to view the BankService.xaml workflow due to the custom activity OperationScope.

  4. Press CTRL+F5 to run the application. The Scenario_Client console prompts you for inputs and the corresponding output is seen in the Scenario console.

Ee662961.Important(en-us,VS.100).gif Note:
The samples may already be installed on your machine. Check for the following (default) directory before continuing.


If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.