SOA223
Introducing Windows Workflow Foundation Building Basic Activities Building Composite Activities Activity Development Advanced Features
A workflow is a set of tasks or activities organized in a pattern To solve a task or model a business process Usually involves interacting with systems or users
Combination Human workflow Peoples and roles Dynamic based on users Uses unstructured data e.g., Document review System workflow Applications and services Prescribed flow Structured data e.g., Supply chain management Line-of-business applications including users and services New-hire provisioning, helpdesk ticket, work item Non-traditional.NET developer tasks such as user interface navigation
Some workflows execute start to finish More often, workflows execute in segments Waiting for input from systems or users between active processing Workflows involve business rules 1. Submit Expense Report For Approval 2. Validate expense report (per diem rates, allowed expenses, total) 3. If not valid, reject and end processing 4. Notify Manager that approval is requested 5. WAIT for manager approval 6. IF the manager does not approve in time, notify next manager 7. WAIT for elevated approval 8. IF Approval, OK expenses and pay, otherwise, reject 9. IF timeout, notify employee to resubmit
Logic and business rules embedded in code Workflow tasks are disconnected in the code Process steps are scattered not declarative Managing instances of a process can be difficult State management falls to the developer Managing the current position and related state Visibility is difficult What has happened and is currently happening?
Single workflow framework for the Microsoft platform Used in Microsoft Office SharePoint Server applications and Microsoft Dynamics CRM today more to come Available to all third parties to build on A toolkit for building workflow into your application Not a server product Does not replace Microsoft BizTalk Server Like Microsoft ASP.NET (you still have to build your Web site) Targeted at.net developers
What you get: Runtime Runtime Services Base Activity Library Rule engine Visual designers What you build: Custom activities Workflows Host application Your own services Custom workflow designer 1. Custom Host Application Custom Workflows Custom Activities Workflow Foundation Base Activity Library Workflow Runtime Runtime Services Workflow Designer Rule engine
Runtime/Execution State Management Bookmarking Business Rules Communications Tracking Dynamic Update Do some work Stop and wait Do some work Stop and wait Do some work
Activities are the building blocks of a workflow Model for reuse and encapsulation Similar to UI design with controls on a form Controls provide the function for a form Controls define what the form does and how it acts Each control has properties, events, methods Come in two different types Basic: performs simple operation, e.g., send a message Composite: controls the execution of child activities
Base set of activities to build workflows Control Flow Communication Scoping Data/Rule-driven Some activities can be extended: Sequence, State, CallExternalMethod, HandleExternalEvent You will often need custom activities
Designer Activity core is a class Attributes define related classes for design and runtime Override base methods Interfaces for certain behaviors Custom Activity Activity Validator [Designer(typeof(CustomActivityDesigner))] [Validator(typeof(CustomActivityValidator))] public class CustomActivity : Activity, ICompensatableActivity { protected override ActivityExecutionStatus Cancel(ActivityExecutionContext ctx){ } protected override HandleFault (ActivityExecutionContext ctx, Exception ex){ } ActivityExecutionStatus Compensate(ActivityExecutionContext ctx){ } }
Derive from System.Workflow.ComponentModel.Activity Define properties and events Override Execute method
public partial class ConsoleWriteLine : Activity { private string texttowrite; public string OutputText { get { return texttowrite; } set { texttowrite = value; } } } protected override ActivityExecutionStatus Execute( ActivityExecutionContext executioncontext) { Console.WriteLine(OutputText); return ActivityExecutionStatus.Closed; }
Runtime Activity Canceling Compensating Initialized Executing Closed Faulting
Each workflow is a class instance The data of the workflow is in the properties Input parameters map to public properties Activities read/write properties on the workflow Output parameters drawn from public properties
Workflows are ideally declarative and composable Need a way to bind data between activities Dependency properties provide support for Binding properties between activities Persistence of state Promoting property values from composite activities
Reuse existing logic by deriving from base class e.g., Derive from sequence Use composite activity designer to define children Much like designing a sequential workflow Useful for building reusable collection of logic Contains properties and events like other activities Simplest implementation
Explicitly control child activity execution e.g., For each, conditional execution, parallel Adds some complexity Must manage activity execution Handle cases of faulting or canceling Provides more control Monitor activities for state changes Extend child activities with custom properties
Composite activities contain other activities May need to expose properties of children Promote the property from the child activity Creates a dependency property on the composite Binds the child activity property to the new property Consumers of composite activity can get/set the value Value automatically propagated to the child
Set value for timeout Promote Timeout Duration
Activity Designer Control the design time experience for your activity Look and feel + interactive features Activity Validator Validate your activities configuration at compile time Listener activities Write activities which can respond to external events
Windows Workflow Foundation provides a framework for managing business logic in an app Services simplify building complex applications Workflows are comprised of activities Base activity library gets you part-way there Activities are your unit of reuse Activities can be basic or composite Dependency properties provide data binding
Moving to a Blended World: Software + Service SaaS Accounting Solution IT Service Portfolio Software+Services Connected User Experience Accounting Portal Customer Support Web 2.0 Composition SaaS Customer Support Solution Manufacturing Enterprise User Core Applications Commodity Applications Devices and People
WF BizTalk It depends Inside Application Between Applications Between Organizations UI Page Controller Dynamically Updateable Process Flow Long Running Business Logic Long Running Business Process Message Broker (EAI) Web Service Composition Web Service Composition Enterprise Service Bus (ESB) B2B Integration Abstraction of Rules from Business Logic Abstraction of Rules from Business Process Enterprise Rule Repository
Breakout Sessions SOA321 Building Microsoft Windows Workflow Foundation Enabled Windows Communication Foundation Services in.net Framework 3.5 SOA322 Rules Engine Use and Extensibility in Microsoft Windows Workflow Foundation Chalk-Talks SOA10 Implementing UI Page Flow with Windows Workflow Foundation SOA01 Incorporating Microsoft Windows PowerShell to Manage Windows Communication Foundation and Windows Workflow Foundation Applications Hands-on Labs SOA13 Microsoft Windows Workflow Foundation Introductory Lab SOA15 Creating Custom Activities with Windows Workflow Foundation
Technical Communities, Webcasts, Blogs, Chats & User Groups http://www.microsoft.com/communities/default.mspx Microsoft Learning and Certification http://www.microsoft.com/learning/default.mspx Microsoft Developer Network (MSDN) & TechNet http://microsoft.com/msdn http://microsoft.com/technet Trial Software and Virtual Labs http://www.microsoft.com/technet/downloads/trials/default.mspx
Take part in the RFID demo at the SOA and WEB Services Booth - for a chance to win one!!!
Complete an evaluation on CommNet and enter to win!
2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.