Click here to Skip to main content
13,405,725 members (57,162 online)
Click here to Skip to main content
Add your own
alternative version


16 bookmarked
Posted 6 Nov 2010

Workflow Service 4.0 is a Major Change: Call WCF Service from Workflow Service 4.0

Rate this:
Please Sign up or sign in to vote.
New changes and features in Workflow service 4.0 provided with a sample solution to invoke WCF service from workflow service


I got a chance to check new Workflow features in Visual Studio 2010 RTM and noticed that there are lots of differences between WF3.5 and WF4. The major replacement is that they removed state machine workflow and provided with a better one “Flow chart” and no more code activity. WCF workflow services 4.0 are implemented very differently, and there are no more code-behind files (sorry to those who are looking for code activity in WF 4.0). All of these changes are done to improve performance and for better understanding of workflows.


This article is presented for those who have some knowledge about workflow 3.0, 3.5 and WCF service, even though all other beginners can learn workflow by downloading the source code.

New Features and Replacements in Workflow 4.0

Have a look at the below picture between work flow templates in 4.0 and 3.5

WF4.0Vs3.PNG - Click to enlarge image

State machine workflow is replaced with Flow chart

As we know, there are two types of workflows in WF3.0 or 3.5, sequential and state machine. You can add activities to these workflows. In WF4, a workflow is an activity which contains other activities. That explains why there is only an Activity Library project template in WF4.Flow chart workflow is a better choice Microsoft has come up with. Most of us know about control of flow chart and this workflow exactly works in the same concept.

No “CodeActivity” and no more code behind

Workflow 4.0 is completely working based on XAML design and there is no more code behind concept. But still anybody wants to call any method, there are proper control items like method invoker and configure type and method name. I will be explaining below in detail how to call the method in WF4.0.

Custom Implementation and Custom Activities

Custom implementation can be done by creating Activity Library and configuring in XAML designer.

Message flow and Workflow Instance

Workflow4.0 services start with Receive Request and End with Send response to the service client. All the implementation can be done between these two main activities.


New workflow instance will be created by checking below property “CanCreateInstance” on “Receive Request” (shown in the above picture). We don’t need to create workflow instance as we used to do earlier.

Creating public variables in Workflow instance

Earlier, we used to create public variables in code behind files but in workflow 4 can allow only create variables from workflow XAML designer. These public variables can be used to pass as parameter or return value in method or any kind of manipulations.

Follow below steps to create variables

  1. Select topmost activity (sequence) and click variables link at the bottom of window.
  2. Give name, type, scope and default as shown below, Custom Type can be given by browse option in drop downs.


Getting Started with Workflows: Calling WCF service from Workflow Service

Overview about Solution structure


As we see, the solution contains two service projects, workflow service and WCF service and Web client to test integration with all these services. Both service contracts are separated since it is not good to mix up both contracts and also easy to define contracts for each client. Data contract is a separate assembly which will be referred across all projects. In this sample application, WCF client is invoking by service factory and even same we can use for invoking workflow service in web client as well.

WCF client Custom Class in Workflow service project

public class SapAdapterClient
public static string VerifyCredit(Basket basket)
return ServiceFactory.CreateInstance<ISapAdapterService>().VerifyCredit(basket); 

This is the custom class which invoke WCF service and return result to Work flow service. WCF client is calling via service factory which will make a call to WCF service.

How to Invoke a Method in Workflow Service

Method invoking can be done easily in workflow services by the following steps:

  1. Create a class in workflowservice project with a method invoking WCF service inside.
  2. Place “Invoke method” activity from tool box under “Primitives”
  3. Click on “Target Type” drop down, click “browse for types” and select class created to invoke WCF service.
  4. Give method name in method name text area.
  5. Click properties and set parameters and result.


Any further information, please download the source code and have a look.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Justin Mathew @ Investment Bank
Engineer British Standard Institute (BSi), London
United Kingdom United Kingdom
My passion is

Microsoft distributed and connecting Technologies like Windows Communication foundation (WCF)
Workflow Services (WWF)
SQL Server
Optimization in all of these

and more @

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
Prasyee24-Oct-12 20:47
memberPrasyee24-Oct-12 20:47 
GeneralMy vote of 2 Pin
Mohammed Lokhandwala30-May-11 2:13
memberMohammed Lokhandwala30-May-11 2:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180221.1 | Last Updated 8 Nov 2010
Article Copyright 2010 by Justin Mathew @ Investment Bank
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid