Wednesday, February 1, 2012

Create Workflow WCF Service using Visual Studio 2010.



Create Workflow WCF Service.

  1. Open Visual Studio 2010.
  2. Setup the Workflow WCF Service project using 'WCF Workflow Service Application' template.

image

  1. Rename ‘Service1.xamlx’ to ‘WorkflowService.xamlx’.

  1. Update 'ReceiveRequest' Activity properties.
    1. Open the Property Window for ‘ReceiveRequest’ activity.
    1. Change ‘OperationName field value to ‘PingService’.
    1. Change ‘ServiceContractName’ to ‘WorkflowService.IWorkflowService’.

  1. Update Workflow Variables in 'Variables' pane.
    1. Click on 'Variables' tab just below the Workflow Designer Area to open it.
    2. Change the 'Variable Type' column of 'data' variable to 'String' type.

           image

  1. Add new activity to implement some logic for Workflow Service.
    1. Open ToolBox Window.
    2. Open 'Primitives' Category.
    3. Drag ‘InvokeMethod’ activity between 'ReceiveRequest' and 'SendResponse' Activities on Workflow Designer.

  1. Write some code which will be invoked by workflow.
    1. Add new class to project with name ‘WorkflowServicePingImp’.
    2. Add a static method to the ‘WorkflowServicePingImp’ class with the name ‘PingResponse’. This method will take a string argument and return a string value as response.
    3. Compile the solutions.

image

  1. Update 'InvokeMethod' Activity properties to invoke our implementation from 'WorkflowServicePingImp' class.
    1. Open the Property Window for ‘InvokeMethod’ activity.
    2. Change the 'TargetType' field value to ‘WorkflowServicePingImp’.
    1. Change the 'MethodName' field value to ‘PingResponse’.
    1. Change the 'Parameters' collection by adding new parameter with 'Value' field as 'data' , 'Direction' as 'In' and 'Type' as 'String'.
    1. Change the 'Result' field value to 'data'.

image
Run and Test the Workflow Service Directly from Visual Studio 2010.
  1. Right click on 'WorkflowService.xamlx' file and click on 'Set As Start Page' to set it as start up page for the project.
  1. Press F5 to run the solution.  ( Visual Studio will run the workflow service in development server in some arbitrary port.)
  1. WCF test client will comp up.
image
  1. Double Click on 'PingService' node on left hand side tree view.
image
  1. Put some string in the 'Value' column in 'Request' panel.
image
  1. Click on 'invoke' button.
  2. Output will be shown in 'Response' panel. 

image

If the above information is useful, Please provide your valuable feedback.
Thanks.

No comments:

Post a Comment