This sample demonstrates how the messaging activities (Receive and 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.
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
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%
Once the URL ACLs are added, use the following steps.
Build the solution.
Set multiple start-up projects by right-clicking the solution and selecting Set Startup Projects.
Add Service and Client (in that order) as multiple start-up projects.
Run the application. The client console shows a workflow running twice and the Service window shows the instance ID of those workflows.
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.
<InstallDrive>:\WF_WCF_Samples\WF\Scenario\Services\Accessing Operation Context