Workflow Foundation 4.0 - WCF Integration

Posted by in WWF category on for Intermediate level | Points: 250 | Views : 24042 red flag
Rating: 5 out of 5  
 2 vote(s)

Workflow Foundation 4.0 is integrated with WCF and WPF. WF 4.0 uses WPF for activity designers and gives a very good support for custom activity designers with full WPF functionality. In this article we will look into the WCF integration to WF4.0.


WCF Integration

When we create a new project, under the workflow project templates, we have the option to select the WCF Workflow Service Application.

Once, we create a WCF Workflow Service application, it will create a default WCF integrated workflow. Note that the extension of our new workflow file is not .xaml, it is .xamlx.

The default WCF workflow will look like

Custom WCF workflow

Now, let us add our own custom FlowChart workflow to the WCF workflow.

  1. Drag and drop a receive activity
  2. Specify the OperationName, which will act as the WCF operation or method name.
  3. Set the CanCreateInstance property of the Receive activity. For running the workflow as WCF service, the current operation should be marked as CanCreateInstance=true.


    4. Click on the Define clause against the Content. The Content Definition window will open. Define your method    parameters here. In our sample, I defined a variable called Name, which I am passing to the operation GetMessage.


5. Now right click on the Receive activity and select Create SendReply option.

This will create the corresponding SendReply activity. Also, workflow will add a new variable for correlating both Receive and Send activities and will link both the activities. SendReply will act as the method which sends the result to the caller.

6. Again, click on the Define clause next to the Content of SendReply activity and define the result. Here I specified a message concatenating my input Name. 


7. Added one Assign activity in between the Receive and Send to manipulate our data. Now, our Custom workflow is ready.




8. Let us verify it using the WCF Test client.
Here I passed the value Susan to Name parameter and observed the result as "Hello Mr/Ms. Susan". “Mr/Ms.” Clause is added to the Name by the Assign activity and the Hello is added by the Send activity.



Host Application

Now, let us see, how we can use the workflow in a host application. Add the WCF workflow reference as the service reference to the host application. We can create the service client object and call the operation just like any other WCF service.


static void Main(string[] args)


            ServiceReference1.Service1Client obj = new ServiceReference1.Service1Client();

            string name="Susan";

            obj.GetMessage(ref name);






Also, just like any other WCF service, we can browse the WCF workflow in browser.


Here, we discussed about the WCF integration with workflow foundation 4.0, how we can test a WCF workflow using WCF Test client and how we can call the WCF workflow from a host application.


Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Ambily KK
Member Level: Silver
Member Status: Member,Microsoft_MVP,MVP
Member Since: 5/18/2010 1:05:25 AM
Country: India
Thanks Ambily K K
I have over 9 years of experience working on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Office Open XML, Azure, Visual Studio 2010. Technology adoption and learning is my key strength and technology sharing is my passion.

Login to vote for this post.

Comments or Responses

Posted by: Karthikanbarasan on: 1/9/2011 | Points: 25
Hi Ambily,

Thanks for this wonderful article... can you help me on how to get started with WWF concepts since im new to this...

Thanks in advance
Posted by: Ambily.raj on: 1/10/2011 | Points: 25

You can refer the WF4.0 introduction Lessons from

Posted by: Karthikanbarasan on: 1/10/2011 | Points: 25
Thanks a lot

Login to post response

Comment using Facebook(Author doesn't get notification)