I downloaded VS.NET 2010 Beta 2 a week ago. But today only i got some free time to install, now i wanted to try new WF /WCF 4.0 .
In this blog i am going to explore WF 4.0 calling WCF 4.0 .
Step1 : Create a WCF service.
Here is my service contract definition and implementation
[ServiceContract(Name="SreeniService")]
public interface IServiceContract
{
[OperationContract]
DateTime GetServerTime();
[OperationContract]
string Greet(string Name);
}
public class SreeniSvc : IServiceContract
{
#region IServiceContract Members
public DateTime GetServerTime()
{
return DateTime.Now;
}
public string Greet(string Name)
{
return "Welcome Mr. "+ Name ;
}
#endregion
}
Step 2: Add new WF project to the existing WCF service project.
Step 3: Add WCF service Reference to WF project.
After adding the Service Reference you must build or compile the project then only All methods or Operations in WCF service will appear as WF activities in the Tool Box as shown below.
Now we need to drag and drop the Sequence activity first to the WF designer surface. because we are going to build workflow using more then one activity . otherwise we will able to drop only one activity in the WF designer surface .
After that Drag and drop the WCF operation Activity GetServerTime on top of the Sequence activity from the Tool Box. This operation returns Datetime so we need to create a variable with this type and assign to this Activity. to crate variable just click Create Variable and choose variable type , Scope and even you can provide default Value .
Now we need to print the GetServerTime Operations Result to the console. To do that we are going to use WriteLine activity from the Tool box and set the Expression as shown below.
Follow the same steps for the Second Operation Greet once you are finished your workflow should look like this.
Now execute the WF project Ctrl+F5 you should see the result as shown below.
Nandri(Thanks)
Sreenivasa Ragavan.
No comments:
Post a Comment