Building a Transparent Process
Transparent workflows let you implement functionality that runs automatically when a service receives a request message or sends a response message. You define a pipeline that contains the transparent workflow, and then associate the workflow with one or more operations. The pipeline is triggered when the operation (called the base operation) is invoked by the client application.
Transparent Workflow Considerations
Unlike other workflow models, transparent workflows require predefined TransparentProcessRequestMessage and TransparentProcessResponseMessage message types, which DCS provides in the Microsoft.ConnectedIndustry.ProcessExecution.Common.dll assembly.
Because of the specific message requirements of transparent workflows, you must create transparent processes in a separate project from other operation types. You implement transparent workflows by using the BLSpecific project type in the same way as you would implement specific and conversational workflows.
Another requirement of a transparent workflow is the use of the WaitForTransparentProcessEvent activity at the beginning of the workflow and the SendTransparentProcessResponse activity at the end of the workflow. For more information, see The WaitForTransparentProcessEvent Activity and The SendTransparentProcessResponse Activity.
To create a new operation to implement transparent workflow functionality
In your DCS solution, right-click the BLSpecific folder, point to Add, and then click BL Specific.
Right-click the BLSpecific project, and then click Add New Operation Request/Response or Add New Operation State Workflow.
In the Add New Operation Request/Response or Add New Operation State Workflow dialog box, on the Operation Configuration page, provide an operation name for the transparent service, and then click Next.
On the Messages Selector page, specify the following message types and then click Next:
-
- Request message: TransparentProcessRequestMessage in the Microsoft.ConnectedIndustry.ProcessExecution.Common.dll assembly.
- Response message: TransparentProcessResponseMessage in the Microsoft.ConnectedIndustry.ProcessExecution.Common.dll assembly.
- Error message: FrameworkError in the Microsoft.ConnectedIndustry.ServiceModel.Common.dll assembly.
- Exception message: FrameworkException in the Microsoft.ConnectedIndustry.ServiceModel.Common.dll assembly.
The assemblies are located in the C:\Program Files\Microsoft CIS\DCS\V1.0\bin folder.
On the Message Assemblies References page, verify that the list contains both assemblies that you added on the Messages Selector page, and then click Finish to complete the wizard.
A transparent operation workflow must start with a WaitForTransparentProcessEvent activity to enable the workflow to receive events from the base workflow and then begin execution.
To configure a WaitForTransparentProcessEvent activity
On the Toolbox, drag a WaitForTransparentProcessEvent activity onto the workflow designer at the top of the workflow process.
-
Note
If you are using a state machine workflow, you must add the WaitForTransparentProcessEvent activity to an EventDriven activity.
In the activity properties, select the type of event to which the workflow responds. For more information about transparent process events, see How the DCS Runtime Injects a Transparent Process into a Service.
-
Note
You can choose to start the workflow when the base operation is invoked, when it ends, each time a message is received or sent (in the event that the base workflow is a conversational workflow), or when the base workflow throws an exception.
Click the Bind Property button for the InputData property. In the Bind 'InputData' to an activity's property dialog box, click Request, and then click OK.
This action binds the incoming message to the Request property in the workflow, which lets you reference it throughout your workflow code. If you want to bind to a different property, you can create new properties in the same dialog box or select one of the other existing properties that are of the correct type.
Implement the remainder of your transparent operation functionality in the same way that you would for any other workflow.
You access the original message that the client application sent to the base operation through the Request.Message property. In this way, you can modify the message before it reaches the client application, or use the contents of the message in your transparent workflow functionality. You can configure the workflow response message that passes back to the client application by using the Response.OutputMessage property.
Note
Depending on the type of event that your transparent workflow responds to, the base operation may run before or after the transparent process completes. The base workflow uses the same message instance as the transparent workflow; any changes that you make will be passed to the base workflow, and the base workflow can overwrite any properties that you set in the messages.
When you have completed the workflow functionality, add a SendTransparentProcessResponse activity to enable the transparent workflow to return any results and terminate correctly.
To configure the SendTransparentProcessResponse activity
- On the Toolbox, drag a SendTransparentProcessResponse activity onto the workflow designer at the end of your operation functionality.
- Set the RelatedActivity property to the WaitForTransparentProcessEvent activity that triggered the operation functionality.
- Set the ResponseState property to enable the call that invoked the transparent process to proceed or stop.
The ResponseState property lets you terminate the entire invocation cycle, including the base workflow invocation. For example, if you detect an exception in the transparent workflow, you can terminate the base operation before it begins, and return an error message to the client application.
After you complete your transparent workflow implementation, save your changes and build your service implementation for deployment and configuration. For more information, see Deploying DCS Services. For more information about invoking a DCS Service from a client application, see Invoking a DCS Service from a Client Application.
See Also
How the DCS Runtime Injects a Transparent Process into a Service
The WaitForTransparentProcessEvent Activity
The SendTransparentProcessResponse Activity