39,59 €
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.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 191
Veröffentlichungsjahr: 2010
Copyright © 2010 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2010
Production Reference: 1170910
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-849680-78-3
www.packtpub.com
Cover Image by Tina Negus (<[email protected]>)
Author
Andrew Zhu
Reviewer
Geert van Horrik
Ryan Vice
Acquisition Editor
Rashmi Phadnis
Development Editors
Dhwani Devater
Technical Editors
Gaurav Datar
Rukhsana Khambatta
Copy Editors
Janki Mathuria
Sanchari Mukherjee
Editorial Team Leader
Gagandeep Singh
Project Team Leader
Priya Mukherji
Project Coordinator
Leena Purkait
Indexer
Monica Ajmera Mehta
Proofreader
Chris Smith
Production Coordinator
Alwin Roy
Cover Work
Alwin Roy
Andrew Zhu has six years of experience of software development and information technology: three years in Java, three years in .NET/C#. During these years, he designed and developed applications including computer language complier, SQL interpreter, Library book management application, online sale application based on JSF/Java, and SharePoint OA application. Two and half years ago he joined Microsoft. Since then, he has been helping developers solve IIS and BizTalk problems, developing .NET/Workflow/ASP.NET/SharePoint applications for his customers. Now, he is a Technology Support Engineer working in Microsoft (Microsoft Globe Tech Support Center), Shanghai. He has been supporting WF4 since its beta1 version.
No book is the product of just the author—he just happens to be the one with his name on the cover.
A number of people contributed to this book, and it would take more space than I have to thank each one individually.
I must thank my colleague Steven Cheng and Packt acquisition editor Rashmi Phadnis—without you, I wouldn't have a chance to write this book. Thanks to Packt Development Editor Dhwani and Project coordinator Leena. You two stayed with me throughout the writing process. I cannot imagine what could come out without your help. Also thanks to Technical Editor, cool Gaurav and Rukhsana Khambatta. My thanks also go to the Copy Editor of this title Sanchari Mukherjee.
I want to thank the reviewers of the book: Ryan Vice, Dave Newton, Geert van Horrik, and Ryan Andrus. Thanks for your patience and comments. Without your effort, the book would have been full of mistakes and incomplete.
I also want to thank my colleagues from Microsoft: XianFeng Zhang, Guang Yang, SGuy Ge, Steve Danielson, Nate Talbert, and Dan Glick. Thanks for your help in the WF and WCF 4.0 discussion list.
Finally, I want to thank my Mom and Dad, thanks for your love and understanding.
Geert van Horrik, after finishing high school in 2001, decided he wanted to learn more about software development. During his education as a software engineer in university, he wrote a some applications using Delphi. Soon, he discovered the power of C++ and started writing open source projects.
During his study, one of his open source projects became very popular, and he spent most of his time writing new features for this project. After finishing education in Software Engineering cum laude, he decided to learn some more about business administration at another university. However, the combination of his addiction to software development and the open source projects made him quit the new study and start a company called CatenaLogic.
The most important product of CatenaLogic is Updater—a tool to easily deploy new versions of software on all clients. Geert van Horrik is also available as a freelance software developer, and mostly concentrates on the latest technologies such as C# and WPF.
Geert also loves helping other people with software development problems on forums, and tries to participate in open source projects in the spare time he has left.
Ryan Vice is an enterprise programmer with 10 years of experience working with Microsoft Enterprise solutions. Over those 10 years, he has worked on network security systems, high-volume e-commerce systems, title management systems, and a high-volume financial trading application. Additionally he has built workflow solutions for a geoseismic system and for a credit counseling management system. He has worked with both thick and thin clients and is currently specializing in the WinFX suite of tools. He was given Microsoft MVP in 2010 for connected systems and is an MSDN moderator. He also frequently teaches classes on WF throughout Texas.
I'd like to thank my father Ken for being a huge inspiration in both my career and my family, my mother Telsa for helping me get my career started, my beautiful wife Heather for all her support and love over the years and willingness to let me spend a lot of my free time tinkering with software technology, my daughter Grace for reminding me of how amazing the simple pleasures in life can be, and my new-born son Dylan for bringing so much more joy and love into our lives.
Microsoft has been putting a lot of resources toward the development of Windows Workflow Foundation (WF). Therefore, before learning this new framework, it's important to understand why Microsoft feels it is so important. For WF 4.0, Microsoft went back to the drawing board and did a complete rewrite of WF technology with the goals of improving WF 3.5 by providing a WF framework that simplifies the development of workflow-based solutions and provides better performance. Microsoft's ultimate goal is to get a higher rate of adoption of WF and to attempt to make WF an essential component of the enterprise developer's tool kit. The questions that most developers and architects, who are first exposed to workflow, will be likely to have are:
These are the questions that need to be answered before you start to learn the details of how to use the WF framework, as learning WF is not a small task and understanding the benefits would go a long way in helping motivate you and your team. This section of the book will help you better understand the "WHYs" of WF and lay the foundation for the rest of the book, which will allow you to hit the ground running by getting up to speed on the "HOWs" of WF. This book consists of short, easy-to-understand examples (or recipes) that show how to take advantage of the many benefits of WF. Your first read will allow you to get familiar with all the various features and extensibility points of the WF 4.0 framework and, as you implement WF 4.0 based solutions, you will find yourself coming back again and again to review these concise, easy-to-understand WF recipes. After reading this short book, you will be ready to simplify your enterprise development architectures by taking advantage of this powerful new workflow framework and all of its built-in, out-of-the-box features.
Let's get to it then… Why workflow? For starters, what kinds of problems does workflow make easier to solve? Let's suppose you need to build a solution for an accounting firm and that firm wants to have a system built to allow them to provide income tax services. This system needs to support the following features.
How would a system like this be built without using a workflow framework? Our first attempt might be to create a set of web services that support:
This income tax process could take several weeks or months to complete and so it's not feasible that we could have a thread on the server waiting for the next input for an account to arrive. For this application to scale and work with any type of realistic enterprise volume, we'd have to persist the state of the account and when each web service request arrives, we'd have to take some kind of identifier (account ID or accountant ID) and retrieve the current state of the account before we could determine if the call could proceed. A client can't submit income tax information before they've created an account and the service for submitting income tax information would have to query our persistence store (database or whatever we are using) to verify this. All of this custom state-management code that would allow for sharing the account data among the various client applications from the various servers would need to be written by the developers including ways to deal with concurrency. We can't allow two clients to update the same data at the same time, so we'd have to provide for that in our implementation.
Assuming we get all that worked out, what about the parts of this process that aren't driven by web-services calls? How are we going to assign clients to accounts after they submit their tax forms? How are we going manage our notifications that will be sent to the clients when:
We'd also need to build a scheduling system and an event routing (or messaging) system to help us satisfy these needs.
How do we deal with scalability? One solution would be to break apart the functional components of the application and deploy each one to a different server or set of servers so that you'd have a server for:
Using this approach would allow us to scale but would make the application logic separated and hard to understand and maintain, as it would be spread over several deployments on different servers.
The ideal solution would be to have a framework that would allow us to:
If we had a framework that allowed for all these things, then it might be worth our time to go out and learn how to use that new workflow framework as it would provide us a lot of built-in benefits that would save us from having to reinvent the wheel over and over again. The good news is that this is only part of what Workflow Foundation provides. In addition to helping solve these problems, WF also provides:
Given all that WF 4.0 brings to the table, it's a worthwhile investment to learn this technology and add it to your enterprise development toolkit, and this book will help to get you up to speed in a very short amount of time.
Ryan Vice
MVP for Connected Systems
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.
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.
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.
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.
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:
Any command-line input or output is written as follows:
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
