Windows Workflow Foundation, sometimes called Windows WF, was developed by Microsoft to provide developers with a single platform on which to develop workflow- or process-based software solutions. Windows Workflow Foundation is built on top of .NET and is a major component of the .NET Framework 3.0.
Because Windows Workflow Foundation is built on .NET and is part of the .NET Framework 3.0, the following sections provide some background and context related to those technologies.
At its core, the .NET Framework is a platform that supports application development and the ability to run software built on the framework. The types of software that you can build on the .NET Framework include web applications with ASP.NET, smart client applications, and XML web services, to name a few. Figure 1-3 is a graphical representation of the .NET Framework stack.
The .NET Framework also provides a managed runtime that allows developers to not worry about memory management as part of writing software. Source code is compiled into Intermediate Language (IL), which is a just-in-time (JIT) compilation at runtime. This means that the IL is changed into machine language that the current operating system can understand and run. This concept enables you to develop software in virtually any language that compiles to IL. Microsoft provides several languages, such as C#, Visual Basic .NET, and managed C++.
Another main pillar of the .NET Framework is the Base Class Library (BCL). The BCL is an extremely large and rich set of classes that provide out-of-the-box functionality for developers. This includes classes for string and XML manipulation, ADO.NET classes for database interaction and structured data operations, and much more.
The .NET Framework 3.0 is a next-generation development platform that is available out of the box on Windows Vista and can also be downloaded for other versions of Windows, including Windows XP SP2 and Windows 2003 Server. Essentially, the .NET Framework 3.0 is an extension of .NET that provides developers with a library of managed APIs. The .NET Framework 3.0 components are as follows:
Windows Presentation Foundation (WPF; formerly known as Avalon)
Windows Communication Foundation (WCF; formerly known as Indigo)
Windows CardSpace (WCS; formerly known as InfoCard)
Windows Workflow Foundation (WF; formerly known as WinOE)
Figure 1-4 illustrates the .NET Framework 3.0 architecture.
Windows Presentation Foundation (WPF), formerly known as Avalon, provides a framework for developing a rich user interface experience. Unlike Windows Forms, which is driven by code, WPF can be developed with a declarative markup model. This markup is called XAML (pronounced zamel), which stands for Extensible Application Markup Language.
XAML is XML based, which means that all you need to develop a user interface layout is your handy Notepad executable. Check out the following code listing for a simple example:
<Window x: xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="XAML Sample" Height="150" Width="200"> <DockPanel> <Button Width="100" Height="50">I am a button!</Button> </DockPanel> </Window>
This creates a form that looks like Figure 1-5.
Although WPF and XAML are separate Windows Workflow Foundation components, XAML plays a role in the declarative model of workflow development (which you learn more about in later chapters).
Windows Communication Foundation (WCF), formerly known as Indigo, is a framework on which you can create SOAs based on industry standards.
SOA is a buzzword of recent years that can cause a lot of controversy when people of the technical persuasion get together to discuss it. Essentially, SOA describes an architecture of loosely coupled services (usually web services) that expose a unique and discrete functionality. Usually, these services perform one very small task, but they perform it well.
Building an SOA at an enterprise is a lot different from building a singular application. SOA provides the foundation to build applications - it is not an application itself. Imagine a company that manufacturers and sells widgets at retail outlets. The organization might have services to submit a bill of materials, to order new widget glue, or to receive and process purchase orders.
Now back to Windows Communication Foundation. One of the biggest advantages of WCF is that it provides a unified platform on which you can develop distributed applications. In the past, if you wanted to develop a distributed application on the Microsoft platform, your options included ASP.NET Web Services (ASMX), .NET Remoting, Enterprise Services, WSE, and MSMQ, to name a few. That’s a daunting list, isn’t it?
WCF uses industry standards such as SOAP to bring all these technologies together. This enables applications built on the Microsoft stack to interact with technologies from other vendors, such as Java. Essentially, WCF is the replacement and glue for these technologies of yesteryear.
Chapter 14 discusses SOA and WCF in greater detail.
Windows CardSpace is a next-generation identity platform. CardSpace is built on open standards and tries to succeed where Microsoft Passport failed. Passport was not able to live up to its grand promises basically because it required your personal information to be stored with Microsoft. CardSpace reverses the location of personal information to your local machine in identity cards. An easy analogy is to consider the cards carried in your wallet, such a driver’s license or library card. Whenever you get pulled over, your license acts as proof of who you are. This is because the card was issued by the state you live in, and the friendly police officer trusts the state, not you.
CardSpace uses this same concept. An identity provider issues identities that are trusted by other sites on the Internet. For example, a credit card company could issue an identity to you that represents a physical card you already have. When you purchase something from an online store, you could present the issued card instead of signing in with a user name and password as you would traditionally. The benefits are twofold in a situation like this. First, you do not have to maintain a user name and password combination for every site you frequent. Second, there is an added layer of security because you are not actually entering credit card information. Rather, because the online store trusts the identity issued by the credit card company, it can use it to take care of the payment details.
In addition to the identity cards issues by third-party providers, you can create self-issued cards. This enables you to create a lightweight identity on a site that requires you to register to obtain access to content, such as a forum. Then the site, if it chose to implement CardSpace, could allow you to authenticate by presenting your self-issued card. This again has the benefit of not requiring multiple user names and passwords. In addition, you can create multiple self-issued cards. This enables you to have identities with varying levels of detail for different types of sites. Figure 1-6 shows an example of a self-issued card in Windows Vista.
Last but certainly not least, Windows Workflow Foundation rounds out the .NET Framework 3.0 platform and is the main topic of discussion in this book.
After reviewing all this information about workflows and process-oriented software, you might be wondering why Windows Workflow Foundation matters. The following paragraphs relate Windows Workflow Foundation to the four tenets of workflow discussed earlier. This should help you determine whether to use Windows Workflow Foundation in your software development efforts.
Workflows coordinate work performed by people and software. This tenet is a key piece of a workflow platform, and Windows Workflow Foundation provides several features that can help you achieve this goal. Workflows built on this framework allow human interaction with basically any interface imaginable - e-mail, web forms, windows forms, instant messaging, InfoPath - the list goes on and on.
The important thing to remember is that the workflow realizes when it is requesting feedback and waits until the required data has been received into the context of the application before progressing. With the Windows Workflow Foundation platform, the possibilities are limited only by your imagination.
Workflows are long running and stateful. Windows Workflow Foundation provides a rich framework of runtime services. These services, which are discussed in detail in Chapter 7, offer you an extensible framework to, among other things, persist running workflows to a durable medium. This is important because workflows can run for long periods of time, and storing a workflow’s context in live memory isn’t practical for many reasons.
If every running workflow in an enterprise had to be stored in memory while waiting for something to happen, the scalability of the system would be nonexistent. The server would run out of memory in no time. In addition, if the server crashed, the volatile memory would be cleared and all data would be lost.
Workflows need to be reliably stateful. Out of the box, Windows Workflow Foundation provides a way for you to persist a workflow’s state to a stable channel such as a database. You can extend these persistence services to store workflow state just about anywhere.
Workflows are based on extensible models. This is a large part of Windows Workflow Foundation - just about every part of the platform is extensible. Workflows are made up of discrete actions called activities. Windows Workflow Foundation provides base activities as well as basic and generic workflow functions. You can extend these activities to meet the needs of essentially any requirement. You can also develop new activities from scratch.
There are many other parts of the platform that are extensible as well. Runtime services provide functionality related to tracking, management, and persistence - which are all extensible.
Workflows are transparent and dynamic throughout their lifecycle. Windows Workflow Foundation meets this requirement in two areas: design time and runtime. Because Windows Workflow Foundation is based on a declarative and visual design-time model, processes are easier to understand. This means you can modify existing workflows without having to change source code.
During runtime, you can query the status and overall general health of workflows. The tracking features of Windows Workflow Foundation also enable you to log information to a persistent medium for later inspection. Finally, and very important, you can modify workflows built on this platform even during runtime. This provides for extremely flexible workflow scenarios.
Aside from the features related to workflow tenets, Windows Workflow Foundation supports both ordered and event-driven workflows. The ordered workflow is implemented as a sequential workflow (as depicted in Figure 1-7), and the event-driven workflow is implemented at a state machine (as depicted in Figure 1-8).
The following sections describe those who should consider using Windows Workflow Foundation and why. (This is by no means an exhaustive list.)
The majority of people who can benefit from using Windows Workflow Foundation on a day-to-day basis are .NET developers. Just like it is a good idea to use the latest version of ASP.NET and SQL Server, boning up on workflow can add to your value as a software professional.
Think about some of the applications and projects you’ve worked on during your career as a developer. You can probably think of several instances where a workflow platform could have come in handy. Now think about workflow in the context of ongoing maintenance of a system that supports a business process. One of the biggest advantages workflow provides to developers is a more efficient maintenance model. Not only is it easier to work with a graphical representation of a process that you developed, but coming up to speed on a workflow someone else developed is also much simpler.
The tools that are part of the .NET Framework, such as ASP.NET, provide you with a rich development environment and enable you to focus on solving business problems rapidly. Windows Workflow Foundation is no exception. By using a platform explicitly geared toward the specific domain of business process, developers can garner a great deal of efficiency and focus.
It is the architect’s never-ending job to evaluate what systems are going to look like from a macro and often a micro level. New technologies come along all the time, and it is up to the architect to determine how these technologies fit in the overall system landscape.
Architects can use workflow to add value to their development efforts and the makeup of a particular enterprise or individual project. They can also use workflows to interact with other pieces of technology. For example, a workflow could coexist and communicate with existing LOB systems.
Although most CIOs don’t care about how Windows Workflow Foundation works or its technical architecture, they should care about some of the benefits such a tool can bring to an enterprise. For one, workflows provide a unified process-oriented development platform. The integration and consolidation of technologies is a key objective for many in technical leadership positions.
In addition, workflow helps bring process to the forefront of software projects. As anyone in a leadership position knows, recent legislation such as Sarbanes-Oxley requires organizations to have a good handle on their processes. Windows Workflow Foundation provides a framework for tracking and monitoring these processes.
One thing Microsoft has been very good at, whether intentionally or not, is fostering a community of vendors that build software on and for Microsoft technologies. Even though Microsoft is the behemoth that it is, it cannot always build software that meets everyone’s needs. This is where Independent Software Vendors (ISVs) and service partners come into play.
ISVs are great at catering to the needs of niche and even mainstream markets. For example, the web controls that come out of the box with ASP.NET, such as the GridView, are great and provide a nice foundation on which to create web applications. However, many industries require more robust controls with clientside capabilities and enhanced editing features. There are many grid controls on the market today that, for a relatively inexpensive price, provide developers with the flexibility and functionality they require.
No doubt it will be the same story with workflow. For example, Microsoft is including a few prebuilt workflows with Office and SharePoint 2007 for documentation and management. However, there may be complex scenarios for specific industries, perhaps healthcare, that will allow technology service providers and ISVs to meet a need not yet met by Microsoft.