Uncategorized

Integrating WWF and WCF (WorkFlow Services)


workflows just making my life easier in developing applications, i have found a good explanation of  why workflow? on why workflow. WCF provide us a new option to use workflow foundation, we can expose our application logic through workflows as webservice.One of the best advantage of work flows is that it can handle asynchronous coordination in application with long running business process.

To create a workflow service project

  1. Start Visual Studio 2010.
  2. Click the File menu, select New, and then Project to display the New Project Dialog. Select Workflow from the list of installed templates and WCF Workflow Service Application from the list of project types. Name the project MyWFService and use the default location as shown in the following illustration.
    Project Dialog.

    Project Dialog.

    when you OK you project dialog, you will find the mentioned files in the solution explorer. change name Service1.xamlx to your appropriate name.

    Solution explorer project objects

    Solution explorer project objects

    When the project is created, the Service1.xamlx file is opened in the designer as shown in the following illustration.

    workflow items sequential workflow

    workflow items sequential workflow

    As we know there are two type of workflow, Sequential Workflows and State Machine Workflows,. Well delete it by right click it. we create our own by drag our own request and response shape. BizTalk has same workflow mechanism but here in WWF 4.0 the shapes are categorical and with bit different options.

    To implement the workflow service

    Select the Toolbox tab on the left side of the screen to display the toolbox and click the pushpin to keep the window open.

    WCF workflow service designer

    WCF workflow service designer

    Drag and drop a ReceiveAndSendReply template to the workflow designer. This creates a Sequence activity with a Receive activity followed by a SendReplyactivity as shown in the following illustration.

    operation name

    operation name

    In the Receive activity type Calculate_Addition the textbox labeled OperationName. This defines the name of the operation the service implements.

    Now we need to make check to initiate a new instance of serivce on receive shape.

    With the Receive activity selected, open the pr

    Right click on the receive shape and click Properties Window scroll down until you see CanCreateInstance and click the checkbox as shown in the following illustration. This setting enables the workflow service host to create a new instance of the service (if needed) when a message is received.

    create instance

    create instance

    Now we need to create the input parameters for our input message and the output message which is also a very simple way to do. Just click on the content text box below the operation name in the receive shape.

    defining varialesdefining variables

    New pop up window will appear where we can defined the variables for our receiving message same as for send shape. In our sample we are calculating two variables so we need two variables bot are type of int32.

    defining input parameters

    defining input parameters

    now set the parameters of out message. Now build the project.

    Debugging the WorkFlow

    We can easily put break points and debug our work flow. In vs2010 we just need to F5 to debug our service on our given break points. What vs 2010 does for us just create a runtime host to invoke method so tat we can debug easily.
    testing service

    testing service

    Now its time to rebuild and deploye our work flow wcf service.
    1. In the Solution Explorer, right-click MyWFService and select Properties to display the Project Properties dialog.
    2. Select the Web tab and select Specific Page under Start Action and type ServiceCalculator.xamlx in the text box as shown in the following illustration.

      build project

      build project

    publish on iis

    publish on iis

Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s