Microsoft Office InfoPath 2003 Training
Lab 12: Human Workflow Services in InfoPath 2003
 

Microsoft Corporation

April 2004

Applies to:
    Microsoft® Office InfoPath™ 2003

Summary: Learn to use Microsoft BizTalk Human Workflow Services (HWS) to create an approval workflow. Create workflows and track them using actions. Create a custom Approval action that uses the HWS Assign and Delegate actions that ship with the BizTalk Server 2004 SDK. Learn how to create an InfoPath form that uses the Approval action. Configure BizTalk Pipeline to process InfoPath forms. For more information about the pipeline component, download the InfoPath 2003 Software Development Kit. (33 printed pages)

Background: InfoPath contains a number of features that help build simple workflow scenarios. Human Workflow Services can be used for advanced integration with BizTalk. Lab 7, User Roles in InfoPath 2003, helps you understand how to use roles, rules, and views to create a simple workflow scenario by presenting only certain controls and views depending on the current role of the user.

Contents

Prerequisites
Scenario
Lab Objective
Server Setup
Exercises

Download the odc_INF03_Labs.exe sample file.

Level

400

Prerequisites

  • An understanding of the Microsoft® Office InfoPath™ 2003 editing environment
  • An understanding of the Microsoft BizTalk® Server 2004 editing environment
  • An understanding of the Microsoft Visual Studio® .NET IDE
  • A conceptual understanding of Human Workflow Services (HWS)

Scenario

An internal analysis at the Contoso Corporation discovered a number of inefficient business processes. Contoso decided to seek feedback about the processes from its employees. The IT department must develop a suggestion form that employees can use to submit process improvement suggestions to management. Subsequently, management needs the ability to assess suggestions from each submitted form and accept, decline, or cancel the request.

Lab Objective

In this lab, use Microsoft BizTalk® Human Workflow Services (HWS) to create an approval workflow. You can use HWS to create workflows and track them using actions. Actions are composed of tasks that users interact with as part of a workflow. InfoPath displays the actions and tasks to the user in the Workflow task pane.

In this lab, you create a custom Approval action that uses the HWS Assign and Delegate actions that ship with the BizTalk Server 2004 SDK. The Approval action allows employees in a corporation to start an approval process. Employees can use an Assign action to assign a task to management for approval. Subsequently, management can use a Delegate action to assign the task to someone who can work on a solution for the issue brought up in the suggestion form.

In this lab, you learn to:

  • Create and deploy an Approval action that uses the HWS Assign and Delegate actions
  • Create an InfoPath form that uses a custom Approval action
  • Configure BizTalk Pipeline to process InfoPath forms

Server Setup

The BizTalk server needs the following tools installed:

Note   Refer to the BizTalk Server 2004 System Requirements for complete server requirements.
  • Microsoft Windows® 2000 or Microsoft Windows® Server 2003
  • Internet Information Services (IIS) 5.0 or IIS 6.0
  • Microsoft SQL Server™
  • BizTalk Server 2004 and Human Workflow Services (refer to your BizTalk documentation for complete BizTalk setup instructions)
  • BizTalk Server 2004 SDK
  • Microsoft® Office 2003 Service Pack (SP) 1 or Microsoft Office InfoPath 2003 SP 1

Exercises

Exercise 1: Create and Deploy the Approval Action that Uses the HWS Assign and Delegate Actions

Use the Assign and Delegate actions that are included in the BizTalk Server 2004 SDK to construct a custom Approval action to use for the approval process.

Deploy the HWS SDK Actions

In this step, you deploy the Assign and Delegate actions included as part of the Human Workflow Services sample in the BizTalk Server 2004 SDK. This step configures the Activation and Interrupt ports that are used by the custom action, Approval.

To deploy the Assign and Delegate actions

  1. From a Microsoft Visual Studio .NET command prompt, go to <BizTalkInstallDir>\SDK\Samples\Hws\Actions\.
  2. Type DeployActions.cmd and press ENTER. This will compile and deploy the necessary assemblies for the Assign and Delegate actions, and will deploy them to your local BizTalk server.

Create a Strong Key File

In this step, you create a key file that will be used as part of the strong name of your assembly.

To create a strong key file

  1. Open a Visual Studio .NET command prompt.
  2. Type the following: sn.exe -k c:\mykeyfile.snk
  3. Press Enter.

Create a Custom HWS Project for the Approval Action

In this step, create an action named Approval.

From Visual Studio .NET, use the BizTalk Server 2004 Human Workflow template to create actions.

To create an HWS project

  1. Open Microsoft Visual Studio .NET.
  2. On the File menu, click New Project.
  3. In the New Project dialog box, in the Project Types pane, click BizTalk Projects.
  4. In the Templates pane, click BizTalk Server Human Workflow Project.
  5. In the Location box, type the location that you would like to save the source files in.
  6. In the Name field, type Approval.
  7. Click OK.

To strong sign the Approval action

  1. On the View menu, click Solution Explorer.

    Figure 1. Solution Explorer

  2. In the Solution Explorer, right-click the Approval project and click Properties.
  3. In the Approval Property Pages dialog box, expand Common Properties.
  4. On the Common Properties node, click General.
  5. In the Application node to the right, in the Assembly Name field, type Approval.
  6. From the Common Properties node, click Assembly.
  7. From the Strong name node to the right, in the Assembly Key File text box, type the location of the strong key file that you created in the section Create a Strong Key file.
  8. Click OK.
  9. On the File menu, click Save All.

To prepare each project file

  1. In the Solution Explorer, click Action.odx.
  2. In the Properties Window, in the File Name field, type Approval.odx.
  3. In the Solution Explorer, double-click Approval.odx.
  4. In the Properties Window, in the Typename field, type StartApproval.
  5. On the View menu, click Solution Explorer.
  6. In the Solution Explorer, click Hws_Activate.xsd.
  7. In the File Name box of the Properties Window, type Hws_Activate_Approval.xsd.
  8. In the Solution Explorer, click Hws_Synchronize.xsd.
  9. In the Properties Window, in the File Name field, type Hws_Synchronize_Approval.xsd.
  10. In the Solution Explorer, click Hws_Task.xsd.
  11. In the Properties Window, in the File Name field, type Hws_Task_Approval.xsd.
  12. In the Solution Explorer, double-click Hws_Activate_Approval.xsd.
  13. In the Properties Window, in the targetNamespace text box, type http://tempuri.org/Hws_Activate_Approval.
  14. Save the targetNamespace; it is used later in the lab.
  15. In the Solution Explorer, double-click Hws_Synchronize_Approval.xsd.
  16. In the Properties Window, in the targetNamespace field, type http://tempuri.org/Hws_Synchronize_Approval.
  17. In the Solution Explorer, double-click Hws_Task_Approval.xsd.
  18. In the Properties Window, in the targetNamespace text box, type http://tempuri.org/Hws_Task_Approval.
  19. On the File menu, click Save All.
  20. On the Build menu, click Build Solution.
  21. On the File menu, click Save All.

At this point, your solution should look like Figure 2.

Figure 2. Solution Explorer

Update the Schemas

After the preparation work for the HWS project is done, it is time to customize the schemas to fit the needs of our Approval action. The Approval action needs the following information as part of the schema:

  • Target. The name of the manager to assign the approval to.
  • Description. The description that the employee provides for the manager.
  • Status. The status of the approval.
  • EndAction. A Boolean value that indicates if the approval is complete or not.

To update Hws_Activate_Approval.xsd

  1. On the View menu, click Solution Explorer.
  2. In the Solution Explorer, double-click Hws_Activate_Approval.xsd.
  3. In the tree view, expand the HwsMessage node.
  4. Click the ActionSection node.
  5. Right-click the ActionSection node, click Insert Schema Node, and then click Child Field Element.
  6. In the placeholder node, type the name Target.
  7. Right-click the ActionSection node, click Insert Schema Node, and then click Child Field Element.
  8. In the placeholder node that appears, type Description.
  9. Right-click the ActionSection node, click Insert Schema Node, and then click Child Field Element.
  10. In the placeholder node that appears, type Status.
  11. Right-click the ActionSection node, click Insert Schema Node, and then click Child Field Element.
  12. In the placeholder node that appears, type EndAction.
  13. Click the EndAction node.
  14. In the Properties section, in the Data Type list box, change the End Action node's data type to xs:boolean.
  15. On the File menu, click Save All.

To create the Activation XML file

This step generates the XML file that is needed later for enabling the Approval action to an InfoPath form.

  1. On the View menu, click Solution Explorer.
  2. Right-click Hws_Activate_Approval.xsd, and then click Properties.
  3. In the Hws_Activate_Approval.xsd Property Pages dialog box, in the General section, in the Output Instance Filename text box, type c:\Activation.xml.
  4. In the Input Instance Filename text box, type c:\Activation.xml.
  5. Click OK.
  6. Right-click Hws_Activate_Approval.xsd, and then click Generate Instance.

To edit the Activation XML file

This step cleans up the Payload section of the generated Activation.xml file to ensure that InfoPath operates properly with HWS. The Payload section transports the InfoPath form as part of the HwsMessage.

  1. In Notepad or another text editor, open the Activation.xml file.
  2. Update the Payloads section so that there is only one Payload element without any nodes.
  3. The resulting Payloads section should look like this:
      <Payloads>
        <Payload ID="ID_0"></Payload>
      </Payloads>
    
  4. Save your changes to the Activation XML file.

To validate the Activation XML file

  1. On the View menu, click Solution Explorer.
  2. Right-click Hws_Activate_Approval.xsd, and then click Validate Instance.

To update Hws_Task_Approval.xsd

The Approval task needs to be modified so that it includes an EndAction element to indicate when a task is complete or not complete. The EndAction node also needs to be promoted as a distinguished node so that code inside this action has access to its value.

  1. On the View menu, click Solution Explorer.
  2. In the Solution Explorer, double-click Hws_Task_Approval.xsd.
  3. In the tree view, expand the HwsMessage node.
  4. Click the ActionSection node.
  5. Right-click the ActionSection node, click Insert Schema Node, and then click Child Field Element.
  6. In the placeholder node that appears, type EndAction.
  7. Click the EndAction node.
  8. In the Properties Window, in the Data Type box, change the End Action node's data type to xs:boolean.
  9. Click the Schema node.
  10. Right-click the Schema node, click Promote, and then click Show Promotions.
  11. In the tree view, expand the HwsMessage node.
  12. In the tree view, expand the ActionSection node.
  13. Click the EndAction node.
  14. Click Add>>.
  15. Click OK.
  16. On the File menu, click Save All.

Create a Map

At this point, you have created an Activation message and a Task message. The Activation message is used to start the Approval action. Once the Approval action is started, an Approval task is generated. When the orchestration receives the inbound activation file, it requires instructions on how to transform any necessary fields into a Task message. In this step, you learn how to use a map to handle this transformation.

To create a map

  1. On the Project menu, click Add New Item.
  2. In the Add New Item – Approval dialog box, in the Templates section, click Map.
  3. Click Open.

To select the source schema

  1. In the left pane of the BizTalk Mapping Editor, click Open Source Schema.
  2. In the BizTalk Type Picker dialog box, expand the Schemas node.
  3. Click Approval.Hws_Activate.
  4. Click OK.

To select the destination schema

  1. In the right pane of the BizTalk Mapping Editor, click Open Destination Schema.
  2. In the BizTalk Type Picker dialog box, expand the Schemas node.
  3. Click Approval.Hws_Task.
  4. Click OK.

To edit the mappings

  1. In the Source Schema pane of the BizTalk Mapping Editor, expand the HwsMessage node.
  2. Expand the HwsSection node.
  3. In the Destination Schema pane of the BizTalk Mapping Editor, expand the HwsMessage node.
  4. Expand the HwsSection node.
  5. Drag the ActivityFlowID node from the Source Schema to the ActivityFlowID node in the Destination Schema.
  6. Repeat the drag-and-connect action of Step 5 for the following:

    Table 1. Source and Destination schema nodes

    Source Schema Node Destination Schema Node
    InitiatingActor InitiatingActor
    InitiatingActor ActorElementXPath
    ActionTypeID ActionTypeID
    ActionInstanceID ActionInstanceID
    ActivityModelTypeID ActivityModelTypeID
    ActivityModelInstanceID ActivityModelInstanceID
    ActivityModelStepID ActivityModelStepID
    HwsWebServiceURL HwsWebServiceURL
    ActionProperties TaskProperties
    ActionProperties\Property TaskProperties\Property
    ActionProperties\Property\Name TaskProperties\Property\Name
    ActionProperties\Property\Description TaskProperties\Property\Description
    ActionProperties\Property\Type TaskProperties\Property\Type
    ActionSection ActionSection
    ActionSection\Target HwsSection\TargetActor
    ActionSection\Status HwsSection\TaskStatus
    ActionSection\EndAction ActionSection\EndAction
    ActionSection\Description HwsSection\TaskDescription
    Payloads Payloads
    Payloads\Payload Payloads\Payload
    Payloads\Payload\ID Payloads\Payload\ID

To enter default values

  1. In the Destination schema, click the PercentageComplete node.
  2. In the Properties task pane, in the Value text box, type 100.
  3. In the Destination schema, click the NumberOfResponses node.
  4. In the Properties task pane, in the Value text box, type 0.
  5. In the Destination schema, expand the Reassignment node.
  6. In the Destination schema, click the ReassignedByActor node.
  7. In the Properties task pane, in the Value text box, type actor.
  8. In the Destination schema, click the FromTaskID node.
  9. In the Properties task pane, in the Value text box, type 00000000-0000-0000-0000-000000000000.

To create a Scripting functoid

  1. On the View menu, click Toolbox.
  2. In the Toolbox task pane, click Advanced Functoids.
  3. Drag the Scripting functoid to the center of the Map, in between the two schema structures.
  4. On the Destination schema, drag the TaskID node to the Scripting functoid.
  5. Click the Scripting functoid.
  6. In the Properties Window, from the Scripting functoid, in the Script box, click the ellipsis (…).
  7. In the Configure Functoid Script dialog box, in the Script type section of the script type drop-down list, click Inline C#.
  8. Replace the Inline script buffer with the following:
    //function to return a GUID in the form of a string
    public string getGuid() {
    return System.Guid.NewGuid().ToString();
    }
    
  9. Click OK.
  10. On the File menu, click Save All.
  11. On the Build menu, click Build Solution.

You should see the message, "Build: 1 succeeded, 0 failed, 0 skipped" in the Output window.

Create the Orchestration

The business logic of the action is the orchestration itself. Within the orchestration, business logic determines how the action should behave.

To create a Message variable

  1. On the View menu, click Solution Explorer.
  2. In the Solution Explorer, double-click Approval.odx.
  3. In the Orchestration View task pane, right-click Messages, and then click New Message.
  4. In the Message Type box of the Properties task pane, click the down arrow.
  5. Expand Schemas and click Approval.Hws_Task.
  6. In the Properties task pane, in the Identifier text box for the new message variable, type TaskMessage.

To add a Construct block

  1. In the Orchestration Designer, locate the DoAllActionSpecificLogicHere block.

    Figure 3. DoAllActionSpecificLogicHere block

  2. From the BizTalk Orchestrations toolbox, drag a Construct Message to the Drop a shape from the toolbox here point.
  3. In the Properties task pane for the Construct block, in the Message Constructed list box, click TaskMessage.

To add a Transform

  1. From the BizTalk Orchestrations toolbox, drag a Transform to the Construct block.
  2. To open the Transform Configuration dialog box, double-click the Transform shape.
  3. In the Transform Configuration dialog box, click existing Map.
  4. In the Fully Qualified Map Name drop-down list, click Approval.Map1.
  5. In the Transform Configuration dialog box, in the Transform node, click Source.
  6. In the Source Transform section, click ActivationMessage from the Variable Name box.
  7. From the Transform node in the Transform Configuration dialog box, click Destination.
  8. From the Destination Transform section, in the Variable Name list box, click TaskMessage.
  9. Click OK.

At this point, your orchestration should look like Figure 4.

Figure 4. DoAllActionSpecificLogicHere block

To add a Send block

  1. From the BizTalk Orchestrations toolbox, drag a Send block and place it below the Construct block.
  2. In the Properties Window, in the Message box, click TaskMessage.

To add a Send port

  1. From the BizTalk Orchestrations toolbox, drag a Port to the Port surface.
  2. In the Port Configuration Wizard, click Next.
  3. In the Name box, type ApprovalOut.
  4. Click Next.
  5. In the Port Type Name box, type PortType_ApprovalOut.
  6. Click Next.
  7. In the Port Direction of Communication drop-down list, click I'll always be sending messages on this port.
  8. Click Next.
  9. Click Finish.

To bind the Send port with the Send block

  1. In the Orchestration Designer, click the Send_1 block.
  2. In the Operation list box of the Properties Window, click ApprovalOut.Operation_1.Request.

At this point your orchestration should look like Figure 5.

Click here for larger image.

Figure 5. DoAllActionSpecificLogicHere block (Click picture to view larger image)

To add a loop

  1. From the BizTalk Orchestrations toolbox, drag a Loop and place it below the Send block.
  2. In the Expression list box of the Properties Window, click the ellipsis (…).
  3. In the BizTalk Expression editor, type
    //boolean expression to test for EndAction flag
    TaskMessage.ActionSection.EndAction == false
  4. Click OK.

To add a Receive block

  1. From the BizTalk Orchestrations toolbox, drag a Receive and place it inside the Loop block.
  2. In the Properties Window, in the Message box, click TaskMessage.
  3. In the Following Correlation Sets property, click corSelfFinishCorrelation.

To add a Receive port

  1. From the BizTalk Orchestrations toolbox, drag a Port and place it on the Port surface.
  2. The Port Configuration Wizard should open to display the Name box. If it does not, click Next.
  3. In the Name box, type ApprovalIn.
  4. Click Next.
  5. In the Port Type Name box, type PortType_ApprovalIn.
  6. Click Next.
  7. In the Port Direction of Communication drop-down list, click I'll always be receiving messages on this port.
  8. Click Next.
  9. Click Finish.

To bind the Receive Port with the Receive Block

  1. In the Orchestration Designer, click the Receive block.
  2. In the Operation box of the Properties Window, click ApprovalIn.Operation_1.Request.
  3. On the File menu, click Save All.
  4. On the Build menu, click Build Solution.

You should see the message, "Build: 1 succeeded, 0 failed, 0 skipped" in the Output window. At this point, your orchestration should look like Figure 6.

Click here for larger image.

Figure 6. Bind the Receive Port with the Receive Block (Click picture to view larger image)

Deploy the Action

When the action is ready to be put into production, you need to deploy the action.

To deploy the action

  • In the Solution Explorer, right-click the Approval project, and then click Deploy.

In the Output window, you should see the message, "Deploy: 1 succeeded, 0 failed, 0 skipped."

Create Ports

The logical ports of the orchestration need matching ports that are bound to physical port locations.

To create the Send port

  1. On the View menu, click BizTalk Explorer.
  2. On the toolbar, click Refresh.
  3. Expand Send Ports.
  4. Right-click Send Ports, and then click Add Send Port….
  5. In the Create New Send Port dialog box, click OK.
  6. In the Name box of the Static-One Way Send Port Properties dialog box, type ApprovalOut.
  7. In the Transport Type box, in the General section, click File.
  8. In the Address (URI) box, in the General section, click the ellipsis (…).
  9. In the FILE Transport Properties dialog box, in the Destination folder text box, type the location of a destination folder.

    Example: C:\ApprovalOut

  10. In the File name text box, type a file name, but leave the %MessageID%.xml. You should have a file name similar to file_name%MessageID%.xml.
  11. Click OK.
  12. From the Configurations node, click Send.
  13. In the Send Pipeline box, click Microsoft.BizTalk.DefaultPipelines.XmlTransmit. Later you will change this to InfoPathPipelineAssembly.
  14. Click OK.

Get the Action Setup

To bind the ports

  1. On the View menu, click BizTalk Explorer.
  2. On the toolbar, click Refresh.
  3. Expand Orchestrations.
  4. Right-click Approval.StartApproval and click Bind.
  5. From the Inbound Ports section, in the ActionActivationPort box, click ActionActivationPort.
  6. From the Inbound Ports section, in the ApprovalIn box, click ActionInterruptPort.
  7. In the ActionInterruptPort box, click ActionInterruptPort.
  8. In the ApprovalOut box, in the Outbound Ports – Static section, click Approval Out.
  9. From the Configuration node, click Host.
  10. In the BizTalk Host section, in the Host box, click BizTalkServerApplication.
  11. Click OK.

To start the action

  1. In the BizTalk Explorer, right-click Approval.StartApproval, and then click Start.
  2. Accept the default settings, and then click OK.

To register the action with HWS

  1. Click Start, click All Programs, click Microsoft BizTalk Server 2004, and then click HWS Server Administration.
  2. Select Actions.
  3. In the right pane, right-click Approval.StartApproval, and then click Register Action: Approval.StartApproval.
  4. Right-click Approval.StartApproval, and then click Properties.
  5. In the Approval.StartApproval Properties dialog box, in the Name box, type Approval.
  6. Click OK.

To create the Constraints

  1. In the HWS Server Administration dialog box, right-click Constraints and select Add Constraint….
  2. In the Add New Constraint dialog box, in the Action drop-down list, click Approval.
  3. In the Constraint Clauses section, select Allow All.
  4. In the EnactedOn Clauses section, select Allow All.
  5. In the Target Clauses section, select Allow All.
  6. Click OK.

To get the ActionTypeID

  1. Open SQL Server Query Analyzer.
  2. In the SQL Server box, type the name of your SQL Server.
  3. Type your credentials.
  4. Click OK.
  5. In Query Analyzer, in the Database selection drop-down list, select BizTalkHwsDb.
  6. In the Query window, type select * from hws_actions.
  7. In the Result window, note the ActionID value for the action that you deployed. You need this ActionID value later in the lab.

Exercise 2: Activating an InfoPath Form to Work with the Approval Action

InfoPath provides a Workflow task pane that allows users to interact with actions and tasks. Now that you have created an Approval action, the next exercise walks you through activating the Approval action for the InfoPath form.

The InfoPath form needs to communicate with HWS workflows so that users can initiate actions and respond to tasks.

To create this channel of communication, you need to perform these tasks:

  • Create a solution. For this lab, this is a new blank form, but it could be an existing form that you are activating to work with HWS.
  • Add Receive Data connections. These Web service data connections allow InfoPath to retrieve the current workflow information and populate the InfoPath Workflow task pane.
  • Add HWS Activation XML required fields. To initiate an action or respond to a task within InfoPath, you need to create the appropriate fields to gather these workflow parameters (target, status, and so on) from the user.
  • Add data nodes and controls to the form. This step creates the view to hold the workflow parameters (target, status, and so on).
  • Add resource files. You need to add the activation.xml file for every action that you want to start in InfoPath. This is done so that InfoPath can create the appropriate message to start actions.
  • Extract form files. This step extracts .cab files for the solution and gives you access to the individual solution files.
  • Enable hwsWorkflow within Manifest.xsf. You need to modify the manifest file to enable the Workflow task pane. You need to indicate the HWS actions and tasks that you want to enable for the form.
  • Enable hwsAdapters within Manifest.xsf. InfoPath provides a set of adapters for you to communicate with HWS. You need these adapters to start a workflow, extend a workflow, and respond to a task.
  • Enable script for the hwsAdapters. The Workflow task pane displays the available actions and tasks that the user can invoke. These are represented as buttons, which define the functionality.

Create a Solution

We need a solution to facilitate working with HWS. In this example, we create a blank form.

To create a blank form

  1. Start InfoPath.
  2. On the File menu, click Design a Form.
  3. In the Design a new form task pane, click New Blank Form.

Add Receive Data Connections

InfoPath uses four Receive Data connections to connect to four Web methods that are exposed by the HWS Web Service. These data connections are case-sensitive and must be named exactly as listed here:

  • GetActivityList
  • GetTaskInfo
  • GetActionInstance
  • GetActivityFlowInfo

To add the GetActivityList Receive Data connection

  1. On the Tools menu, click Data Connections.
  2. In the Data Connections dialog box, click Add.
  3. In the Data Connection Wizard dialog box, click Receive data.
  4. Click Next.
  5. In the Data Connection Wizard dialog box, click Web service.
  6. Click Next.
  7. In the Data Connection Wizard, in the Enter the location of the Web service you want to use as your data connection: box, type http://HWS_serverName/HWSService/HWSService.asmx.
  8. Click Next.
  9. In the Select an Operation list box in the Data Connection Wizard dialog box, click GetActivityList.
  10. Click Next.
  11. Click Next.
  12. In the Enter a name for this data connection: box, type GetActivityList.
  13. Clear the Automatically retrieve data when form is opened check box.
  14. Click Finish.
  15. Click Close.

To add the GetTaskInfo Receive Data connection

  1. On the Tools menu, click Data Connections.
  2. In the Data Connections dialog box, click Add.
  3. In the Data Connection Wizard dialog box, click Receive data.
  4. Click Next.
  5. In the Data Connection Wizard dialog box, click Web service.
  6. Click Next.
  7. In the Data Connection Wizard, in the Enter the location of the Web service you want to use as your data connection: box, type http://HWS_serverName/HWSService/HWSService.asmx.
  8. Click Next.
  9. In the Select an Operation list box in the Data Connection Wizard dialog box, click GetTaskInfo.
  10. Click Next.
  11. Click Next.
  12. In the Enter a name for this data connection: box, type GetTaskInfo.
  13. Clear the Automatically retrieve data when form is opened check box.
  14. Click Finish.
  15. Click Close.

To add the GetActionInstance Receive Data connection

  1. On the Tools menu, click Data Connections.
  2. In the Data Connections dialog box, click Add.
  3. In the Data Connection Wizard dialog box, click Receive data.
  4. Click Next.
  5. In the Data Connection Wizard dialog box, click Web service.
  6. Click Next.
  7. In the Data Connection Wizard, in the Enter the location of the Web service you want to use as your data connection: box, type http://HWS_serverName/HWSService/HWSService.asmx.
  8. Click Next.
  9. In the Select an Operation list box in the Data Connection Wizard dialog box, click GetActionInstance.
  10. Click Next.
  11. Click Next.
  12. In the Enter a name for this data connection: box, type GetActionInstance.
  13. Clear the Automatically retrieve data when form is opened check box.
  14. Click Finish.
  15. Click Close.

To add the GetActivityFlowInfo Receive Data connection

  1. On the Tools menu, click Data Connections.
  2. In the Data Connections dialog box, click Add.
  3. In the Data Connection Wizard dialog box, click Receive data.
  4. Click Next.
  5. In the Data Connection Wizard dialog box, click Web service.
  6. Click Next.
  7. In the Data Connection Wizard, in the Enter the location of the Web service you want to use as your data connection: box, type http://HWS_serverName/HWSService/HWSService.asmx.
  8. Click Next.
  9. In the Select an Operation list box in the Data Connection Wizard dialog box, click GetActivityFlowInfo.
  10. Click Next.
  11. In the Parameters list box in the Data Connection Wizard dialog box, click s0:detailLevel to give it focus.
    Note   The actual namespace prefix may be different. If so, look for *:detailLevel.
  12. Click Set Value.
  13. In the Sample value drop-down list in the Parameter Details dialog box, click ActionInstanceLevel.
  14. In the Parameter Details dialog box, click OK.
  15. In the Data Connection Wizard dialog box, click Next.
  16. In the Enter a name for this data connection: box, type GetActivityFlowInfo.
  17. Clear the Automatically retrieve data when form is opened check box.
  18. Click Finish.
  19. Click Close.

At this point, your Data Connections dialog box should look like Figure 7.

Figure 7. Add the GetActivityFlowInfo Receive Data connection

Add HWS Activation XML Required Fields

An HWS action requires an Activation XML instance that validates against the activation schema. This can vary for each action created by the HWS Orchestration Designer. Values for fields that are required in the Activation XML instance need to be supplied by InfoPath. Following is the actionSection fragment of a sample Activation XML instance. It is important to note that the sample can vary from action to action.

<ActionSection>
   <Target>Target_0</Target>
   <Description>Description_0</Description>
   <Status>Status_0</Status>
   <EndAction>false</EndAction>
</ActionSection>

To add the Target node

  1. On the View menu, click Data Source.
  2. Click myFields to give it focus.
  3. Click Add.
  4. In the Add Field or Group dialog box, in the Name box, type Target.
  5. In the Type drop-down list, click Field (element).
  6. In the Data type drop-down list, click Text (string).
  7. Click OK.

To add the Description node

  1. On the View menu, click Data Source.
  2. Click myFields to give it focus.
  3. Click Add.
  4. In the Add Field or Group dialog box, in the Name box, type Description.
  5. In the Type drop-down list, click Field (element).
  6. In the Data type drop-down list, click Text (string).
  7. Click OK.

To add the Status node

  1. On the View menu, click Data Source.
  2. Click myFields to give it focus.
  3. Click Add.
  4. In the Add Field or Group dialog box, in the Name box, type Status.
  5. In the Type drop-down list, click Field (element).
  6. In the Data type drop-down list, click Text (string).
  7. Click OK.

To add the EndAction node

  1. On the View menu, select Data Source.
  2. Click myFields to give it focus.
  3. Click Add.
  4. In the Add Field or Group dialog box, in the Name box, type EndAction.
  5. In the Type drop-down list, click Field (element).
  6. In the Data type drop-down list, click True/False (Boolean).
  7. Click OK.

At this point, your Data Source pane should look similar to Figure 8.

Figure 8. Add the EndAction node

Add Data Nodes and Controls to the Form

In addition to the necessary nodes needed for the activation file, you may want additional data nodes to hold other data. The structure is limited only by the InfoPath solution developer.

After the data nodes are added, controls should be placed on the form so that the user can interact with the data.

To add data nodes to the form

  1. On the View menu, click Data Source.
  2. Click myFields to give it focus.
  3. Click Add.
  4. In the Add Field or Group dialog box, in the Name text box, type DataNodes.
  5. In the Type drop-down list, click Group.
  6. Click OK.
  7. Select DataNodes to give it focus.
  8. Click Add.
  9. In the Name box, type DataItem.
  10. In the Type drop-down list, click Field (element).
  11. In the Data type drop-down list, click Text (string).
  12. Select the Repeating check box.
  13. Click OK.

At this point, your Data Source pane should look like Figure 9.

Figure 9. Add data nodes to the form

To add controls to the form

  1. On the View menu, click Data Source.
  2. Right-click myFields and then click Controls in Layout Table.
  3. Using the resize handles, resize the Layout table as necessary.

At this point, your form should look like Figure 10.

Click here for larger image.

Figure 10. Add controls to the form (Click picture to view larger image)

To change the Status control to a populated drop-down list box

  1. Right-click the text box to the right of the Status field in the Layout table, click Change To, and then click Drop-Down List Box.
  2. Double-click the drop-down list box to the right of the Status field in the Layout table to open the Drop-Down List Box Properties dialog box.
  3. Select Enter list box entries manually from the List box entries section of the Drop-Down List Box Properties dialog box.
  4. Click Add.
  5. In the Add Choice dialog box, in the Value text box, type InProgress.
  6. In the Display text box, type InProgress.
  7. Click OK.
  8. Repeat steps 4 through 7, adding the following values:

    value:   Accepted       display:   Accepted

    value:   Completed    display:   Completed

    value:   Declined       display:   Declined

    value:   Deferred       display:   Deferred

    value:   NotStarted    display:   NotStarted

    value:   Tentative      display:   Tentative

    value:   Waiting         display:   Waiting

    value:   Cancelled      display:   Cancelled

    value:   Interrupted   display:   Interrupted

  9. Click OK.
  10. Click Select… to give it focus.
  11. Click Remove.
  12. Click OK.

At this point, your Drop-Down List Box Properties should look like Figure 11.

Change the Status control to a populated drop-down list box

Figure 11. Change the Status control to a populated drop-down list box

Add Resource Files

To be able to start an action within HWS, each action requires an activation file, which must be added as a resource to the InfoPath solution. You created this file (C:\Activation.xml) previously in the lab.

To add the Activation.xml file as a resource

  1. On the Tools menu, click Resource Files.
  2. In the Resource Files dialog box, click Add.
  3. In the Add File dialog box, in the File name text box, type <Lab_files>\Lab 12\Figures\Activation.xml or add the Activation XML file created in the Create Activation XML file section of the Setup portion of this lab.
  4. Click OK.
  5. Click OK.

At this point, the Resource Files dialog box should look like Figure 12.

Figure 12. Add the Activation.xml file as a resource

Extract Form Files

You must manually edit some of the files by using Extracting Form Files.

To extract form files

  1. On the File menu, click Extract Form Files.
  2. Select a folder and click OK.
  3. On the File menu, click Close.

Activating hwsWorkflow within Manifest.xsf

The activation of HWS within the manifest is controlled by two sections. The first is the hwsWorkflow section. This section determines:

  • Whether the HWS Workflow task pane is activated.
  • Which actions exposed by the HWSService GetActivityList are supported within the solution (in this case, we are only using one Action, Approval).
  • Which tasks users can respond to.

The following is a fragment from a sample manifest.xsf file. Two actions and two tasks are defined in the sample. Note that in this lab, the HWS service is configured with only the first action. The second action is displayed here only to show that you can enable an InfoPath solution with more than one HWS action.

<xsf:hwsWorkflow taskpaneVisible="yes">
   <xsf:location url="abc"></xsf:location>
      <xsf:allowedActions>
      <xsf:action name="Approval" actionTypeID="12A3CDE9-FAC9-4B42
       -2BD1-A0EFCEA03062" canInitiateWorkflow="yes" caption="Start 
       Approval"></xsf:action>
      <xsf:action name="Delegate" actionTypeID="F8E1453A-0813-1E96
       -D42C-FFC41C50E5C7" canInitiateWorkflow="no" caption="Delegate 
        Task"></xsf:action>
      </xsf:allowedActions>
      <xsf:allowedTasks>
         <xsf:task name="RespondToApproval" 
           taskTypeID="http://tempuri.org/Hws_Task_Approval" 
            caption="Respond To 
     Approval"></xsf:task>
         <xsf:task name="RespondToDelegate" 
           taskTypeID="http://tempuri.org/Hws_Task_Delegate" 
           caption="Respond To Delegate"></xsf:task>
      </xsf:allowedTasks>
   </xsf:hwsWorkflow>

To add the hwsWorkflow section to Manifest.xsf

  1. Open the manifest.xsf file in Notepad or another text editor.
  2. Copy the preceding hwsWorkflow section fragment and paste it directly within the xDocumentClass element.
  3. Copy the ActionID value retrieved from the SQL database earlier in Exercise 1 for your deployed actions, and replace the actionTypeID value for the action element.
    <xsf:action name="Approval" actionTypeID="12A3CDE9-FAC9-4B42
       -2BD1-A0EFCEA03062" canInitiateWorkflow="yes" caption="Start 
       Approval"></xsf:action>
    
  4. Copy the targetNamespace from the Hws_Task_Approval.xsd created in Exercise 1, and replace the taskTypeID value for the task element.
    <xsf:task name="RespondToAssign" 
    taskTypeID="http://tempuri.org/Hws_Task_Approval" 
    caption="Respond To Approval"></xsf:task>
    
  5. Save the changes to the manifest.xsf file.

Enable hwsAdapters within Manifest.xsf

The second section within the manifest needed to enable HWS is hwsAdapter(s). HWSAdapters are custom adapters, based on the InfoPath Web service adapters that inherently call into the HWSService Web service. Also, the InfoPath XML instance is encoded into base64Binary data and placed within a PayLoad element in the submitted message. For each action that can be enabled within InfoPath, there can be the following hwsAdapter types:

  • addActionToNewActivityFlow
  • addActionToActivityFlow
  • sendTaskResponse

To add the addActionToNewActivityFlow adapter type

  1. Open the manifest.xsf file in Notepad or another text editor.
  2. Copy and paste the following element directly into the xDocumentClass element.
    <xsf:dataAdapters>
    </xsf:dataAdapters>
    
  3. Copy and paste the following fragment into the dataAdapters element.
    <xsf:hwsAdapter name="Approval" wsdlUrl="http://
          HWS_Server_Name/hwsservice/hwsservice.asmx?WSDL" 
          submitAllowed="yes" queryAllowed="no">
       <xsf:hwsOperation type="addActionToNewActivityFlow" 
              typeID="12A3CDE9-FAC9-4B42-2BD1-A0EFCEA03062" 
              serviceUrl="http://
              HWS_Server_Name/hwsservice/hwsservice.asmx?op=
             GetActivityList">
          <xsf:input source="Activation.xml">
             <xsf:partFragment match="ActionSection/Target"
                replaceWith="/my:myFields/my:Target"></xsf:partFragment>
             <xsf:partFragment match="ActionSection/Description" 
                replaceWith="/my:myFields/my:Description"></xsf:partFragment>
             <xsf:partFragment match="ActionSection/Status" 
               replaceWith="/my:myFields/my:Status"></xsf:partFragment>
             <xsf:partFragment match="ActionSection/EndAction" 
               replaceWith="/my:myFields/my:EndAction"></xsf:partFragment>
          </xsf:input>
       </xsf:hwsOperation>
    </xsf:hwsAdapter>
    
  4. Copy the ActionID value retrieved earlier in Exercise 1 for your deployed actions, and replace the typeID value for the addActionToNewActivityFlow submit adapter.
    <xsf:hwsOperation type="addActionToNewActivityFlow" 
    typeID="12A3CDE9-FAC9-4B42-2BD1-A0EFCEA03062"
    
  5. Update the HWS_server_name with the name of your HWS server.
  6. Save the changes to the manifest.xsf file.

To add the addActionToActivityFlow adapter type

  1. Open the manifest.xsf file in Notepad or another text editor.
  2. Copy and paste the following fragment as a sibling to the preceding adapter.
    <xsf:hwsAdapter name="ExtendApproval" wsdlUrl="http://
           HWS_Server_Name/hwsservice/hwsservice.asmx?WSDL" 
           submitAllowed="yes" queryAllowed="no">
       <xsf:hwsOperation type="addActionToActivityFlow" 
         typeID="12A3CDE9-FAC9-4B42-2BD1-A0EFCEA03062" serviceUrl=
            "http://HWS_Server_Name/hwsservice/hwsservice.asmx">
          <xsf:input source="Activation.xml">
             <xsf:partFragment match="ActionSection/Target" 
               replaceWith="/my:myFields/my:Target"></xsf:partFragment>
             <xsf:partFragment match="ActionSection/Description" 
               replaceWith="/my:myFields/my:Description"></xsf:partFragment>
             <xsf:partFragment match="ActionSection/Status" 
                 replaceWith="/my:myFields/my:Status"></xsf:partFragment>
             <xsf:partFragment match="ActionSection/EndAction" 
                replaceWith="/my:myFields/my:EndAction"></xsf:partFragment>
          </xsf:input>
       </xsf:hwsOperation>
    </xsf:hwsAdapter>
    
  3. Copy the ActionID value retrieved earlier in Exercise 1 for your deployed actions, and replace the typeID value for the addActionToActivityFlow submit adapter.
    <xsf:hwsOperation type="addActionToActivityFlow" typeID="
       12A3CDE9-FAC9-4B42-2BD1-A0EFCEA03062"
    
  4. Update the HWS_Server_Name with the name of your HWS server.
  5. Save the changes to the manifest.xsf file.

To add the sendTaskResponse adapter type

  1. Open the manifest.xsf file in Notepad or another text editor.
  2. Copy and paste the following fragment as a sibling to the preceding adapter.
    <xsf:hwsAdapter name="RespondToApproval" 
         wsdlUrl="http://HWS_Server_Name/hwsservice/
         hwsservice.asmx?WSDL" submitAllowed="yes" queryAllowed="no">
       <xsf:hwsOperation type="sendTaskResponse" 
           typeID="http://tempuri.org/Hws_Task_Approval" serviceUrl=
           "http://HWS_Server_Name/hwsservice/hwsservice.asmx">
          <xsf:input source="">
             <xsf:partFragment match="HwsSection/Status" 
               replaceWith="/my:myFields/my:Status"></xsf:partFragment>
             <xsf:partFragment match="ActionSection/EndAction" 
              replaceWith="/my:myFields/my:EndAction"></xsf:partFragment>
          </xsf:input>
       </xsf:hwsOperation>
    </xsf:hwsAdapter>
    
  3. Copy the targetNamespace value retrieved earlier in Exercise 1 for your deployed actions, and replace the typeID value for the sendTaskResponse submit adapter.
    <xsf:hwsOperation type="sendTaskResponse" 
    typeID="http://tempuri.org/Hws_Task_Approval"
    
  4. Update the HWS_Server_Name with the name of your HWS server.
  5. Save the changes to the manifest.xsf file.

Activate Script for the hwsAdapters

Script handlers are needed to get the hwsAdapters to submit to HWS. Therefore you must add a script file to the solution.

To add a script file

  1. Right-click manifest.xsf and then click Design.
  2. On the Tools menu, click Programming, and then click Microsoft Script Editor.
  3. If prompted, install the Microsoft Script Editor.
  4. Copy and paste the following text into the Microsoft Script Editor script.js file.
    function Approval::OnClick(eventObj)
    {
       XDocument.DataAdapters.Item("Approval").Submit();
    }
    function RespondToApproval::OnClick(eventObj)
    {
       XDocument.DataAdapters.Item("RespondToApproval").Submit();
    }
    function ExtendApproval::OnClick(eventObj)
    {
       XDocument.DataAdapters.Item("ExtendApproval").Submit();
    }
    
  5. On the File menu, click Save, and then click Exit.

Add Button for addActionToActivityFlow

For addActionToNewActivityFlow and sendTaskResponse hwsAdapter types, a button is automatically generated in the HWS Workflow task pane. In order to interact with the addActionToActivityFlow hwsAdapter, add a button.

To add a button for addActionToActivityFlow

  1. On the Insert menu, click More Controls.
  2. On the Controls task pane, in the Insert Controls section, click Button.
  3. Double-click Button to open the Button Properties dialog box.
  4. In the Button Properties dialog box, on the General tab, in the Label text box, type Extend Approval.
  5. In the ID box of the Button Properties dialog box, on the General tab, type ExtendApproval.
  6. Click OK.

At this point, your Button Properties should look like Figure 13.

Figure 13. Button properties

At this point, your solution should look like Figure 14.

Click here for larger image.

Figure 14. Add a button for addActionToActivityFlow (Click picture to view larger image)

Exercise 3: Configure HWS Pipeline to Handle InfoPath Forms

The HwsMessage contains the InfoPath form (stored as base64Binary) as part of the PayLoad element. As HWS processes the HwsMessage to generate the appropriate taskIDs for a workflow, it is necessary to update the InfoPath form's workflow IDs so that the form is synchronized with HWS. This is done by inserting a component on the HWS pipeline that handles this interaction.

To set up the custom pipeline component

Pipelines allow messages to take varied paths from a source to a destination. Along the paths, the pipeline component can interact with the message payload.

InfoPath forms are stored as base64Binary data within the Payload node of the HWS message. A custom pipeline is needed to unpack the base64Binary nodes, update the processing instructions, and repack the node. This interaction takes place after the message is sent from the source (action), and before it arrives at the destination (physical drop point).

This exercise shows how to set up a custom pipeline. You need the HWSInfoPathPipelineComponent.cs file included in the sample files.

To create a Strong Key file

  1. From a Microsoft Visual Studio .NET command prompt, type sn –k myKey.snk.
  2. Note the location where the key file was created.

To build the Pipeline component

  1. Create a Microsoft Visual C#® Class Library project in Visual Studio .NET 2003 named InfoPathPipelineComponent.
  2. Delete the Class1.cs file from the project.
  3. Add the HWSInfoPathPipelineComponent.cs file, included with the sample files, to the project.
  4. Add a reference to BizTalk_installation_directory\Microsoft.BizTalk.Pipeline.dll.
  5. On the View menu, click Solution Explorer.
  6. In the Solution Explorer, double-click AssemblyInfo.cs.
  7. In the assembly: AssemblyKeyFile entry, type the location of the strong key file.

    Your entry should look similar to this:

    [assembly: AssemblyKeyFile(@"<strong key location>\myKey.snk")]
    
  8. On the Build menu, click Build Solution.

Copy the Pipeline Component dll

  • From the pipeline components \bin\Debug folder, copy InfoPathComponent.dll to <BizTalkInstallDir>\Pipeline Components\.

Build the Pipeline Assembly

  1. Create an empty BizTalk Server project named InfoPathPipelineAssembly.
  2. On the View menu, click Solution Explorer.
  3. On the Project menu, click Add New Item and then click Send Pipeline.
  4. Click Open.
  5. In the Solution Explorer, double-click SendPipeline1.btp.
  6. On the Tools menu, click Add/Remove Toolbox Items. . ..
  7. In the Customize Toolbox dialog box, click the BizTalk Pipeline Components tab.
  8. Click Browse.
  9. In the File name box of the Open dialog box, type <BizTalkInstallDir>\Pipeline Components\InfoPathPipelineComponent.dll.
  10. Click OK.
  11. In the Customize Toolbox dialog box, on the BizTalk Pipeline Components tab, in the Name column, select the box next to BizTalk 2004 HWS – InfoPath 2003 SP1 Integration Component.
  12. Click OK.
  13. Add BizTalk 2004 HWS – InfoPath 2003 SP1 Integration Component to the first stage (Pre-Assemble) of the Pipeline Component.
  14. On the Project menu, click Properties.
  15. Under Common Properties, click Assembly.
  16. In the right pane, under Strong name, type the location and name of the Assembly Key File.
  17. Click OK.
  18. On the Build menu, click Build Solution.
  19. In the Solution Explorer, right-click the InfoPathPipelineAssembly project, and then click Deploy.

Edit the ports

  1. Open Visual Studio .NET 2003.
  2. On the View menu, click BizTalk Explorer.
  3. On the toolbar, click Refresh.
  4. In the BizTalk Explorer, expand Send Ports.
  5. Double-click ApprovalOut.
  6. From the Configuration node, click Send.
  7. Under Send Pipeline, select InfoPathPipelineAssembly.SendPipeline1.
  8. Click OK.

Run the Solution

At this point, the InfoPath solution is activated to work with the Approval action on the HWS server.

To run the solution

  1. To open the solution in InfoPath, double-click the manifest.xsf file.
  2. The HWS Workflow task pane should show a Start Approval button.
  3. In the Target field, enter a valid target that has permissions to start a workflow within HWS. For the sake of this lab, you could use the domain\administrator account for this BizTalk server.
  4. In the Status drop-down list, click InProgress.
  5. On the Workflow task pane, in the Start Workflow section, click Start Approval. You should see this message: "Your response has been successfully submitted. To view the most recent status for this workflow, click Get Status."
  6. Click Get Status.

    At this point, the InfoPath window should look similar to Figure 15.

    Click here for larger image.

    Figure 15. InfoPath window (Click picture to view larger image)
  7. Navigate to the drop file location and open the XML file.

    Example: C:\ApprovalOut

  8. In the Status drop-down list, click Completed.
  9. Select the End Action check box.
  10. In the Workflow task pane, click Respond To Approval.
  11. In the Workflow task pane, click Get Status.
  12. Repeat Step 11 until you see the update status.
  13. In the InfoPath form, in the Workflow task pane, click Get Status.
  14. The updated status should now reflect a Completed workflow.