Professional Documents
Culture Documents
Workflow Foundation
Silvano Coriani
(silvano.coriani@microsoft.com)
Developer Evangelist
Microsoft
Agenda
What is Windows Workflow
Foundation?
Architecture & Core concepts
Building Workflows
Introduction to Activities
Workflow Styles
Workflow Authoring Tools
Runtime services
Workflow communications
Software Challenges
Orders are
confirmed in
48 hours and shipped
within 30 days
Most suppliers
confirm our orders
but some forget and
we need to followup
Transparency
Rendering runtime state
within a visualization of
the workflow control
flow
For Example
to provide Windows
Workflow
Foundation as a
part of the
developer
framework for
Windows
and enterprise
applications that
build on top of
Windows Workflow
Foundation for
For Example
An enterprise customer
uses BizTalk Server to
provide system workflow
across their existing line
of business applications
and trading partners to
reduce their cycle-times
and increase business
visibility in a high-volume
environment.
Redefining workflow
What is a workflow?
A set of activities that coordinate people
and / or software...
Example activities. EscalateToManager
CheckInventory
Or a state diagram.
System Workflow
CRM
Business
Business to
to Business
Business
Supply
Supply Chain
Chain Mgmt
Mgmt
Line
Line of
of Business
Business Apps
Apps
ERP
Quote to
to Cash,
Cash, Sales
Sales Automation
Automation
Quote
IT
IT Management
Management
New H
Hire
ire Provisioning,
Provisioning, Trouble
Trouble Ticket,
Ticket,
New
.NET
.NET Developer
Developer
Pageflow, Service
Service Coordination
Coordination
Pageflow,
Components
Base Activity Library: Out-of-
Visual Designer
A Workflow
An Activity
Custom Activity Library
Windows
Workflow Foundation
Base Activity Library
Runtime Engine
Runtime Services
Host Process
Workflow Basics
A workflow is a class
Imports System.Workflow.Activities
Public Class MyWorkflow
Inherits SequentialWorkflow
End Class
</SequentialWorkflow>
Workflow Execution
My Application
Create instance
rt.StartWorkflow(typeof(WF1));
WF1 Instance
Sequence
WF1
OnEvent1
Execute
MyWF.dll
Invoke1
Instance Manager:
Loads workflow type
Creates instance
Enqueues WF1 with Scheduler
Base
Activity
Library
Runtime
Engine
Runtime
Services
SequentialWorkflow
Execute
Sequence
Execute
Save
Activity
Persist to disk
Instance Manager
Scheduler
Sequence
WF1
OnEvent1
7
Persistence
WF1
Activity Basics
Activities are the building blocks of workflows
The unit of execution, re-use and composition
Basic activities are steps within a workflow
Composite activities contains other activities
EG: Sequence
Base Activity Library provides out-of-the-box activity set
Partners and customers author custom activities
EG: ApproveOrder
Designer
[Validator(typeof(MyValidator))]
Validator
[CodeGenerator(typeof(MyCodeGen))]
Serializer
[Serializer(typeof(MySerializer))]
Code Generator
[ToolboxItem(typeof(MyToolboxItem))]
ToolboxItem
Behaviors
[SupportsTransaction]
[SupportsExceptionHandlers]
public class MyActivity: Activity
{ ...
}
Transactions
Custom Activity
Libraries
Domain-Specific
Workflow Packages
Compliance
Compose
activities
Out-of-Box
Activities
OOB activities,
workflow types,
base types
General-purpose
Activity libraries define
workflow constructs
CRM
Extend
activity
Author new
activity
Create/Extend/
Compose activities
App-specific
building blocks
First-class citizens
RosettaNet
IT Mgmt
Vertical-specific
activities & workflows
Best-practice IP &
Knowledge
Sequential Workflow
Step1
Step2
Sequential
structure
prescribes
processing order
Prescriptive, formal
Automation scenarios
Flowchart metaphor
Event
State1
Event
State2
Reactive, event-driven
Skip/re-work, exception handling
Graph metaphor
Rules-driven Activities
Rule1
Step1
Data
Rule2
External
events drive
processing
order
Step2
Data-driven
Simple Conditions, complex Policies
Constrained Activity Group
Spectrum of Workflow
Authoring
Tools
Line of Business
Manager / End users
Wizards
Business Analyst
Visio Like
Sequential
Designer
State Machine
Designer
Activity Designer
Workflow Designers
( la ASP.NET Designer)
Create new workflows
Visual (/code) authoring
Seamlessly integrate .NET
code with round-tripping
Visual debugging
Themes support
Designer re-hosting
Activity Designer
( la UserControl Designer)
Create new activities
Visual (/code) authoring
Inherit from base activities or
start from scratch
Black-box/Gray-box
composition support
XAML C#/V
B
XML defines
XML defines
workflow structure workflow
logic and data flow Code-beside
defines extra
logic
Code Only
C#/V
B
Code creates
Code creates
workflow
in constructor
Application
Generated
App creates
activity
tree and
serializes
XAML C#/V
B
Workflow Compiler
wfc.exe
assembly
ctor defines
workflow
.NET
C#/VB Compiler
OutLook:
Receive
notifications
and track tasks
SharePoint:
Start/participate
, customize, and
track workflows
Word, PowerPoint,
FrontPage:
Excel, InfoPath:
Create and
Start/participate in
customize
SharePoint workflo
workflows
Workflows run inside SharePoint
and are accessible across the
Office System
Runtime Engine
Runtime Services
Persistence
Communication
Tracking
Host Process
Runtime Services
The workflow runtime is lightweight
Depends on a set of services
Only Threading is required
Often you also want Transactions and Persistence
Runtime Services
Host Application
App Domain
Runtime
TimerService
manages timers
e.g. Delay activity.
PersistenceService
stores and
retrieves instance
state.
TrackingService
manages profiles
and stores tracked
information.
Common resource
services for
managing
threading and
creating
transactions
Services
TimerService
PersistenceService
TrackingService
ThreadingService
TransactionService
SQL
Out-of-Box Services
ASPNetThreadingService
Synchronous threading service used for inline execution; used by ASP module for web
services
DefaultThreadingService
InMemoryTimerService
SqlTimerService
SqlStatePersistenceService
SqlTrackingService
Tracking
Track all state changes and data within the workflow
Emit tracking info from code
Dynamic changes
Profile
XML file that specifies what to track
Includes and excludes, state changes, data context, types
Object model to create
Tracking
Information
Activities
Workflow
Instance
Profile
Tracking
Service
Write
Host
Applicatio
n
Query
Store
Tracking Architecture
Workflow Runtime
Workflow Instance
Profile
SqlTrackingService
Listener
Execution
FileTrackingService
Profile
Communication Architecture
Local Application
Custom
Host
Remote Application
ASP.NET
Web Service
Local
LocalApp
AppObject
Object
Workflow Runtime
Communication
Services
Proxy management
Correlation
Runtime
Scheduling
Workflow Instances
InvokeMethod
EventSink
WebServiceReceive
WebServiceResponse
InvokeWebService
Activities
Model sending and
receiving of data
Four components:
Local Communication Activities
Contract
Local Service
EventArgs
Application
Workflow
Workflow Runtime
Output
Input
Method
DataExchangeService
Event
EventSink activity
Model an event raised by a local object
(Application Workflow)
InvokeMethod activity
OrderManager
WorkflowRuntime
} it raises an event
}
Coordinating Services
Workflows are an excellent way to coordinate services
Service interaction becomes:
Declarative modeled using activities in a workflow
Transparent - to the outside world
Visual for designing, debugging, and monitoring
Composable - Data can be flowed from activities/services
Simplified - Workflows simplify message exchange patterns
Flexible - Easily be modified and dynamically changed
Workflow
Services
Services
Workflow
Parameter binding
WebServiceReceive, WebServiceResponse
Model 1-way and 2-way requests to the workflow
Define web service contract as an interface
Parameter binding
Generate default web service project plus artifacts
with a single click in Visual Studio
WorkflowWebService
Default base class for published workflows
Not a required base class for your web services
WebTimerService
Persistent timer service
Web Services
ASP.NET
WorkflowWebService
WorkflowWebHostingModule
Build transparent,
flexible, longrunning web
services
Model all data entry
and exit points
Workflow Runtime
Workflow
Receive
Response
Invoke
Runtime Services
Threading Service
Timer Service
Persistence Service
Session
Timers
Workflow State
Workflow
Services
Secure, reliable,
transactional services
Unified API for
communications
Transport selection
Multiple Message
Exchange Patterns
WCF Activities
Prototype activities designed for direct
communications using WCF
SendMessage
ReceiveMessage
SendReceive
ReceiveSend
Service Request
WCF
Service
Accelerators
Orchestratio
Workflow
n
Messaging
Transformati
on
Adapters
Busine
ss
Activity
Monito
r
And
Admin
Tools
Windows
Workflow
Foundation
WinFX
Workflow framework
Summary
A single workflow technology for Windows