Introduction : The Window Communication Foundation (WCF) is service-oriented application. With the help of WCF we can send a data from one service to another. The Workflow is simply encapsulate activities for Window Communication Foundation. WCF is designed to offer a manageable approach to creating Web services and Web service clients.

Step 1 : Open Visual Studio.

wf1.gif

After OK the following activity show.

wf``.gif
Step 2 :
Drag activity from Toolbox.

wf2.gif

Step 3 : Define Variables for application.

wf3.gif

Step 4 : Go to Solution Explorer and right-click in project option.

wf4.gif

Write down the following code:

Code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using System.IO;
namespace DeclarativeServiceLibrary1
{
public sealed class CodeActivity1 : CodeActivity
{
// Define an activity input argument of type string
public InArgument<string> Text { get; set; }
// If your activity returns a value, derive from CodeActivity<TResult>
// and return the value from the Execute method.
public OutArgument<string> result { get; set; }
protected override void Execute(CodeActivityContext context)
{
// Obtain the runtime value of the Text input argument
string text = context.GetValue(this.Text);
File.AppendAllText(@"C:\WorkflowLog.txt", "Result is:" + text);
context.SetValue(result, "Result is:" + text);
}
}
}


Step 5 : Go to the Design option.

wf5.gif

Step 6 : Double-click in Flowchart.

wf6.gif

Step 7 : Click on CodeActivtiy1.

Value :

(operat1 * operat2).ToString()

Similarly for add, subtract define a Text Value.

wf7.gif

Step 8 : Press F6 and Build the application.

Step 9 : Now we define the service path for the application.

wf8.gif

Step 10 : Go to the Web option.

wf10.gif

Step 11: Press F5 and run the application.

Step 12 : Right-click in My Service Project.

wf111.gif

Step 13 : Now we click calculate option and add thee any parameter.

wf12.gif

Click in Invoke option Find the result.

wf13.gif