Mapping WF 3 activities to WF 4

Matt's Musings

Syndication

First, this post is not about any automated tools for mapping your activities, so don’t get too excited. :)   Instead, I wanted to take the opportunity to talk about the changes to the base activity library in the context of the activities available today in WF 3.  If you are using WF today, there are some activities that have direct counterparts, while others are split into multiple activities and yet others disappear completely.  Of course there are also some new activities that were not available in WF 3.  In the tables below, I outline each of these different categories with some notes.  Hopefully this mapping helps you see what is changing, what is new, and what goes away. 

NOTE: this information is based on Beta 1 of WF 4 and some changes are possible, though nothing big is likely, between now and the RTM. 

Activities with direct or indirect equivalents

WF3 Activity WF4 Activity Notes
Delay Delay The activity works the same, but the timers are handled differently in the framework.
Sequence Sequence  
Parallel Parallel Similar, but the internals of execution may differ slightly by RTM. 
Replicator ForEach<T>, ParallelForEach<T>,
ForEach, ParallelForEach
These provide <optional> typed access to the instance data and truly declarative authoring experience.  Each represents the different execution modes of the Replicator activity – so it has been split into four similar activities.  I think most people will use the generic versions more than the others, but time will tell.
CallExternalMethod InvokeMethod, InvokeMethod<T> Provides .NET method invocation and optional return of a typed return value.  This can be a call on an instance stored in a variable or a static method.
HandleExternalEvent Receive, ReceiveAndSendReply WCF messaging activities replace the Local communications model, even for host-> workflow communication. 
Listen Pick The Pick activity is the primary WF4 activity that replaces the Listen and the State which were both containers for EventDriven activities. 
EventDriven PickBranch This is an indirect mapping and you don’t use the PickBranch outside the pick, but it serves the same basic purpose of the EventDriven. 
Compensate Compensate Though the mechanism are slightly different, the activity serves the same purpose – to execute the compensation handler for a compensable scope. 
CompensatableSequence CompensableActivity The new activity includes a ConfirmationHandler which can execute when a confirmation is signaled using the Confirm activity. 
FaultHandler(s) TryCatch The try catch logic is more explicit now and you use the TryCatch activity to model your fault handling instead of using fault handlers on the composite activities. 
IfElse If In WF 4, this can only have two branches, the If and the Else.  For more branches, use the switch activity.
InvokeWebService Send, SendAndReceiveReply All web service communication in WF4 uses WCF. 
Throw Throw  
TransactionScope TransactionScopeActivity  
WebServiceInput (output and fault) Receive, ReceiveAndSendReply WCF is THE messaging system to use with WF.
While While/DoWhile WF4 introduces the DoWhile in addition to the While to ensure the first iteration executes.

 

WF3 Activities with no direct WF4 equivalent

WF3 Activity Note
ConditionedActivityGroup Based on limited use (my guess) this activity was not moved to WF4.
Code There is no code-behind file for workflows so there is no place to write code in the workflow.  Create custom activities or use expressions where appropriate. 
EventHandlingScope No real equivalent, probably b/c this is an activity that gets overlooked or people use the state machine instead. 
InvokeWorkflow In the Beta, there is no activity like this one.  One option is to host child workflows as WCF services and use the Send or SendAndReceiveReply messaging activities to start the child workflows. 
Policy In order to use rules in WF4, create a WF3 activity with a Policy activity inside it.  Create properties on the activity and use them in the policy definition.  Then use the InteropActivity to invoke the WF3 activity and execute the policy.  You can use the properties on the activity as input and outputs to the policy.
Suspend In WF4 there is more focus on having a “suspend on error” style exception handling, so direct suspend is not currently supported in the form of an activity.
SynchronizationScope Again, my assumption here, this was not used a lot by folks so didn’t get moved over. 
Terminate No direct option to terminate, but exception handling has changed so that when a workflow throws an exception, you can abort, terminate or cancel it. 
CompensatableTransactionScope In WF4, use a Compensable activity and put a TransactionScopeActivity in the body. 
State, StateInitialization, StateFinalization There is no State Machine workflow in WF 4. 

 

WF4 activities with no direct WF3 equivalent

AddToCollection<T> Helper activity to simplify declarative workflow development and manipulation of collection variables.
Assign Assigns a value to a variable – useful for declarative workflows. 
CancellationScope Allows you to define a scope of work and the steps to take if that work is canceled.  Replaces the cancelation handler in WF3. 
ClearCollection<T>  
Confirm Schedules the Confirmation logic for a Compensable activity. 
ExistsInCollection<T>  
Persist Explicit declaration of persistence from the workflow. Replaces the need for the PersistOnClose attribute on activities.
RemoveFromCollection<T>  
Switch<T> Provides multiple branches of execution each based on a specific result from evaluating an expression. 
Interop Executes a WF3 activity in the context of a WF4 workflow.  All public properties on the activity become In/Out arguments.  Custom designers are not supported. 

Posted Jun 26 2009, 01:45 PM by matt-milner

Comments

on 06-26-2009 4:14 PM

SOA/WCF/REST/WF Jesus Rodriguez has his slide deck on WOA from SOAWorld 2009 available Also, he has Using WCF 4.0 XAML Services in the real world: Activating WCF Services from a Central Repository SOA Security Testing - XML Gateways WCF Load Test Tool

DotNetShoutout wrote Mapping WF 3 activities to WF 4 - Matt Milner - Pluralsight Blogs
on 06-27-2009 3:06 PM

Thank you for submitting this cool story - Trackback from DotNetShoutout

Mike Taulty's Blog wrote Catching up on blog reading…
on 07-03-2009 8:57 AM

It was very warm and humid last night in Manchester, UK and so I sat up late catching up on a whole bunch

Bogdan Nedelcu wrote re: Mapping WF 3 activities to WF 4
on 01-22-2010 12:18 AM

Hello. I just read your article and I'm surprised about the missing feature "State machine". What was the reason and how shall we able to handle this useful pattern ?

Any ideas ?

matt-milner wrote re: Mapping WF 3 activities to WF 4
on 01-22-2010 9:12 AM

Bogdan, I think it was a matter of limited time to get proper testing in order to ship.  The current recommendations are to either a) use state machines in the system.workflow.activities assembly and then either use the interop activity if you want to run in the new framework, or just run using the same code you would in WF3.  Or you can b) move to the Pick/PickBranch activities to implement a similar pattern.  Check out the migration docs for more information:

go.microsoft.com/fwlink

Matt

uberVU - social comments wrote Social comments and analytics for this post
on 01-24-2010 11:13 PM

This post was mentioned on Twitter by JnManso: Liked: Mapping WF 3 activities to WF 4 http://bit.ly/AwSQ4

Fred Morrison wrote re: Mapping WF 3 activities to WF 4
on 03-23-2010 6:44 PM

1. None of the WF4 goodness is available for use in SharePoint 2010 workflows, so tell me again why, as a SharePoint 2010 developer of custom workflows, I should be excited about WF4?

2. No ConditionedActivityGroup pretty much kills any hope of upgrading any of the custom workflows I've written for client over the past 2 years.  The CAG is the heart-and-soul of many of those custom workflows.  I'd love to hear some official reason why that particular activity wasn't kept in WF4 and why no suitable replacement is available.

matt-milner wrote re: Mapping WF 3 activities to WF 4
on 03-23-2010 9:46 PM

Fred, it is a bit disappointing to not have WF4 in SharePoint, but the timetables didn't line up for the releases.  

As for the CAG?  I'm not official, but I think the reason was that not many customers were using it.  Clearly, you were a customer who is using it, which means the transition is harder.  The good news is that writing a custom activity in WF4 is much easier, and duplicating the CAG functionality would not be very hard at all.  

vijay wrote re: Mapping WF 3 activities to WF 4
on 05-13-2010 8:09 AM

Thanks , this list is really helpful.

Don't know how much time i sent looking for InvokeWebService :-(

I have one suggestion/correction for section "WF3 Activities with no direct WF4 equivalent"

InvokeWorkflow - Article says "there is no activity like this one. "

Actually all workflows being activities can be directly called in another workflow without using WCF. (similar to calling Writeline, Assign activity)

matt-milner wrote re: Mapping WF 3 activities to WF 4
on 06-15-2010 9:01 AM

Vijay, that's true, you can use any workflow just like an activity, so you can include it directly in your workflow.  What isn't there out of the box, and maybe for the best, is the ability to invoke the activity asynchronously.  Most people I knew were trying to work around the fact that the InvokeWorkflow activity as async anyway.  

Add a Comment

(required)  
(optional)
(required)  
Remember Me?