Export (0) Print
Expand All

Accessing OperationContext

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

This sample demonstrates how the messaging activities (Receiveand Send) can be used with a custom scope activity to access Current and attach or retrieve a custom message header within an outgoing or incoming message.

Demonstrates

Discussion

This sample shows how to use extensibility points (ISendMessageCallback) IReceiveMessageCallback) in the messaging activities to access Current. The callbacks are registered within the workflow runtime as an implementation of IExecutionProperty that is picked up by the messaging activities upon execution. Any messaging activity in the same scope as that IExecutionProperty implementation is affected. In particular, this sample uses a custom scope activity to enforce the callback behavior. The ISendMessageCallback is used in the client workflow to include the workflow’s Id as an outgoing MessageHeader. This header is then picked up in the service using the IReceiveMessageCallback and the value of the header is printed out to the console.

To set up, build, and run the sample

  1. This sample exposes a workflow service using HTTP endpoints. To run this sample, proper URL ACLs must be added (see Configuring HTTP and HTTPS for details), either by running Visual Studio as Administrator or by executing the following command at an elevated prompt to add the appropriate ACLs. Ensure that your Domain and Username are substituted.

    netsh http add urlacl url=http://+:8000/ user=%DOMAIN%\%UserName%
    
  2. Once the URL ACLs are added, use the following steps.

    1. Build the solution.

    2. Set multiple start-up projects by right-clicking the solution and selecting Set Startup Projects.

    3. Add Service and Client (in that order) as multiple start-up projects.

    4. Run the application. The client console shows a workflow running twice and the Service window shows the instance ID of those workflows.

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

<InstallDrive>:\WF_WCF_Samples

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.

<InstallDrive>:\WF_WCF_Samples\WF\Scenario\Services\Accessing Operation Context

Community Additions

ADD
Show:
© 2014 Microsoft