by Keyvan Nayyeri via Keyvan Nayyeri on 8/7/2007 5:54:17 PM
Windows Workflow Foundation in .NET Framework 3.5 comes with two new activities: SendActivity and ReceiveActivity. These are two new services to work with WCF services. The first one, SendActivity, can be used to send requests to WCF services and the second one, ReceiveActivity, can be used to receive the response from services.
In this post I talk about the SendActivity and in one of upcoming posts, I'll cover ReceiveActivity.
First, let me create a WCF service for this example which has a contract like this:
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace MyService
{
[ServiceContract]
public interface IMyService
[OperationContract]
string GetResponse(string value);
}
And a service implementation like this:
public class MyService : IMyService
#region IMyService Members
public string GetResponse(string value)
return string.Format("Hello {0}!", value);
#endregion
I host this service on IIS 7.0.
On workflow side, you need to add references to your service assembly to have access to its types. Moreover, you have to use Add Service Reference to add reference to your WCF service (this is a new replacement for Add Web Reference in Visual Studio 2008).
Now, I add two activities to my workflow: a SendActivity and a Code activity. SendActivity sends a request to service and calls the GetResponse() method to get the result and store it in a DependencyProperty in workflow. Code activity simply writes this property to console.
After adding the SendActivity activity to workflow, you should set some properties in order to make it set it up. Here is a list of important properties to set:
Now I add a simple code to show the response from DependencyProperty in console so the final code for the workflow looks like this:
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace SendActivitySample
public sealed partial class Workflow1 : SequentialWorkflowActivity
public Workflow1()
InitializeComponent();
public static DependencyProperty sendActivity1__ReturnValueProperty = DependencyProperty.Register("sendActivity1__ReturnValue", typeof(System.String), typeof(SendActivitySample.Workflow1));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Parameters")]
public String sendActivity1__ReturnValue
get
return ((string)(base.GetValue(SendActivitySample.Workflow1.sendActivity1__ReturnValueProperty)));
set
base.SetValue(SendActivitySample.Workflow1.sendActivity1__ReturnValueProperty, value);
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
Console.WriteLine(GetValue(Workflow1.sendActivity1__ReturnValueProperty));
Now I run my workflow to get the following result:
Original Post: SendActivity in Windows Workflow Foundation 3.5
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.