Book Image

Microsoft Windows Workflow Foundation 4.0 Cookbook

By : Andrew Zhu
Book Image

Microsoft Windows Workflow Foundation 4.0 Cookbook

By: Andrew Zhu

Overview of this book

Windows Workflow Foundation 4.0 (WF) is a significant part of .NET Framework 4.0. WF makes workflow technology available to every single programmer that uses the .NET Framework 4.0. It is easy to create long running and distributed programs using WF with the right knowledge. With this book, you will discover that working with workflows is easy. This book provides both step-by-step recipes and relevant background information. It covers all the important aspects of Windows Workflow Foundation 4.0. The best thing about this book is that all recipes are based on real-world experiences of Andrew Zhu. Andrew is a global WF and BizTalk technology support engineer for Microsoft. This book covers everything you need to know, when working with workflows. Get to grips with flow control activities, messaging, and transaction processes with easy to understand steps followed by explanations. You will quickly learn to use collection and custom WF activities and WF services.You will see recipes that illustrate integration of Windows Workflow with other applications such as WPF, ASP.NET, WCF service.Lastly, you will discover how easily you can customize W4 Designer with WF rule engine and others.
Table of Contents (15 chapters)
Microsoft Windows Workflow Foundation 4.0 Cookbook
Credits
About the Author
About the Reviewers
Foreword
Preface
Index

Preface

WF4 is a process engine, as well as a visual program language, shipped along with Microsoft .NET Framework 4.0. Traditionally, when we design a long-running application, we break a large application into lots of small code blocks to address the business logic and use a database to store the intermediate data. With the growing complexity of logic, managing code blocks and authoring logic workflows becomes difficult. Now, with WF4, we can design and create distributed, long-running programs easily.

The aim of this book is to provide a step-by-step guide to help us start WF4 programming. Every recipe in this book is runnable.

What this book covers

Chapter 1, Workflow Program, provides recipes that will help us understand basic information about WF4 programming.

Chapter 2, Built-in Flow Control Activities, provides recipes that demonstrate the usage of the built-in control activities.

Chapter 3, Messaging and Transaction, provides recipes that demonstrate how to send and receive WCF messages in workflow. The second part of this chapter focuses on applying transactions in a workflow program.

Chapter 4, Manipulating Collections, demonstrates how to manipulate collection data in workflow programs with WF4 built-in activities.

Chapter 5, Custom Activities, demonstrates how to create our own custom activities; the most powerful unit of workflow.

Chapter 6, WF4 Extensions, demonstrates how to use the built-in extensions such as persistence and tracking, and also how to create our own extensions.

Chapter 7, Hosting Workflow Applications, mainly explains how to host workflow applications in IIS7. This chapter also provides recipes that demonstrate host workflow in ASP.NET, WPF, and Windows Forms.

Chapter 8, Custom Workflow Designer, helps us create our own WF4 workflow designer with visual tracking function.

What you need for this book

We need a PC having Windows Vista/7/2008/2008R2. We can also use Windows XP, but it is not recommended. .NET Framework 4.0 is a must. Once we install .NET Framework 4.0, we can run workflow applications. To develop WF4 workflow applications, we should also have Visual Studio 2010 installed on our computer. To host WF4 as a WCF service in IIS, we should install IIS7/7.5 in our computer.

Who this book is for

If you find yourself working with Windows Workflow Foundation 4.0 and you have basic knowledge of C#/.NET Framework/VB and workflow, this book is for you. It will be best if you know both C# and VB, because WF 4.0 expressions can be written only in VB (at the time of writing). With this book, you will be able to enhance your applications with flexible workflow capabilities using WF 4.0. To follow the recipes, you will need to be comfortable with .NET Framework, C# programming, and the basics of SOA and how to develop them.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The ActivityLibrary project is for all customized activities, whereas the WorkflowConsoleApp project is used for testing our customized activities".

A block of code will be set as follows:

class Program {
    static void Main(string[] args) {
        WorkflowInvoker.Invoke(GetCodeStyleWorkflow());
    }

Any command-line input or output is written as follows:

.NET Framework 4 Full (32-bit) – silent repair
%windir%\Microsoft.NET\Framework\v4.0.30319\SetupCache\Client\setup.exe /repair /x86 /x64 /ia64 /parameterfolder Client /q /norestart

New terms and important words are shown in bold. Words that you see on the screen, in menus, or dialog boxes for example, appear in our text like this: "Click the Invoke button to get the result".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an e-mail to , and mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Tip

Downloading the example code for this book

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.