Previous Articles
Introduction
Microsoft.NET 4.0 and Visual Studio.NET 2010 ships a lot of new features in their underlying technologies. In this series of articles, I want to talk about the new features in the area of Windows Communication Foundation (WCF) in order to improve the development experience, enable more communication scenario, support new WS-* standards and provide a good integration with Windows Workflow Foundation (WF).
The new features are essentially the following: simplified configuration, standard endpoints, IIS hosting without a SVC file, support for WS-Discovery, routing service, REST improvements, enhancements for the integration with WF to support workflow services, simple byte stream encoding and ETW tracing.
In this series of article, I will illustrate each feature explaining the principles and showing some examples.
Workflow Services
Workflow Service is a new approach to build integration solutions where we have a combination of WCF and WF programming model and related technologies into one paradigm. WF gives you a declarative programming model raising the level of abstraction when exposing and consuming the business logic. This is a very good technology to support the principles of an integration solution where we specify the orchestration of services (functionality exposed by the system to be integrated) as well as to expose this orchestration (the implementation of a business logic) as service.
WF provides a good model for implementing long-running orchestration that need to wait for external events in an asynchronous way. So, the combination of WCF and WF programming model and related technologies enable the developers to have a very robust workflow technology such as BizTalk Server or Oracle SOA. Of course, BizTalk Server and Oracle SOA (Workflow Services is a not substitutive product but a complement) are server solutions to execute orchestration in an enterprise environment to guarantee the quality of services such as performance and availability. The bottom line is we're replacing lines of code in the implementation of the service operation with a composition of activities.
The main artifacts to integrate WCF and WF in Microsoft.NET 4.0 are the workflow services, the new class WorkflowServiceHost and the set of WCF messaging and workflow activities. Workflow services are defined in XAML files with a .xamlx extension. These xamlx files contain the description of the workflow, the activities and endpoint configurations not defined in the configuration file.
In order to illustrate the concepts of Workflow Services, I will develop a solution to support the simple scenario where we receive a message, do some processing and send a response back to the client. This scenario could be very complex such as consuming external services, waiting for some events, and so on. The implementation strategy is to use Workflow Services paradigm and new features of WCF 4.0.
The first step is to open Visual Studio.NET 2010 and create a new project. In the New Project window, select the Workflow node and then WCF Workflow Service Application template (see Figure 1).
Figure 1
When the project is created, we have mainly two files, the Service1.xaml with the definition of the workflow and the Web.config with the application configuration specifically with configuration of the WCF service with configurations for endpoints, bindings and behaviors.
If you see the workflow designer, by default, the workflow service contains a Receive activity followed by a Send activity. The Receive activity enables that when one incoming message is received, then a new instance of the workflow is created. This behavior of configured by setting the CanCreateInstance property of the Receive activity to true. The Receive activity contains the GetData operation. You can change the name of the operation with OperationName property(see Figure 2).
Figure 2
The Receive activity also has the Content property for binding the incoming messages to local variables within the Sequence activity (see Figure 2). If you click on the Content property, the Content Definition window appears, and you see that incoming messages are bound to the data variable of type Int32 (see Figure 3).
Figure 3
You can see the list of variables associated to the Sequence activity by clicking on the Variables tab underneath the workflow designer (see Figure 4).
Figure 4
Let's create the EchoService as we've done in previous articles of the series. First of all, let's rename the service from Service1.xamlx to EchoService.xamlx in the Solution Explorer window as well as the ConfigurationName and Name properties of the Service in the Properties window (see Figure 5).
Figure 5
Next step is to change the name of the operation to GetMessage and define a new variable named inMessage of type String within the Sequence (see Figure 6).
Figure 6
Next step is to bind the Content property of the Receive activity to the inMessage variable (see Figure 7).
Figure 7

nagendra singhPosted Jul 8, 2011, 9:48 AM
nice article sir..............please continue it
Vijay Kumar ReddypoguPosted Mar 21, 2011, 3:44 PM
Too good and Nice.
Mahesh ChandPosted Aug 31, 2010, 1:58 AM
Nice reading. Keep up the good work.