|
|
YOUR FEEDBACK
|
TOP MICROSOFT .NET LINKS BizTalk
An Interface for Human Workflow Services in BizTalk Server 2004
A focus on interaction
By: Matt Milner
Feb. 9, 2005 12:00 AM
Digg This!
One of the lesser known or least understood features of BizTalk Server 2004 is Human Workflow Services (HWS). This Web services-enabled platform provides most of the tools you need to build robust workflow solutions. One of the missing tools is a user interface that understands and can work with this great feature. With the release of Service Pack 1 for InfoPath 2003, Microsoft introduced new features that provide developers with the tools they need to use InfoPath as the user interface for workflows, thus taking full advantage of InfoPath's natural XML editing capabilities. The source code for this article is available at http://sys-con.com/dotnet/. BizTalk Human Workflow Services HWS is made up of a few key components that are important to understand before trying to build a workflow solution. Each of these components is defined below with a brief explanation of the role each plays in the process.
Before the release of Service Pack 1 for Office 2003, the steps defined above had to be handled in a developer's code by calling to the HWS Web service for each of these steps, and any UI for interacting with these steps had to be created from scratch. While InfoPath provided the capability to call Web services and send InfoPath documents to those services, much of this work was done in the Microsoft Script Editor when using HWS. The new features in SP1 handle the calls to the service, creating a workflow pane that provides buttons for initiating actions, responding to tasks, and checking the status of an activity flow. The one thing that InfoPath SP1 does not provide is a nice user interface for configuring these features. The point of this article is to provide the information you need to correctly configure an InfoPath solution to interact with your HWS actions.The following sections will walk through creating an InfoPath solution using predefined HWS actions, highlighting the details that you really need to understand. Steps to Get InfoPath to Interact with HWS Four receive data connections (shown below) need to be added to the InfoPath solution. Using the Tools/Data Connections menu item, add each of these connections as receiving data from the HWS Web service on your BizTalk server. In each case you should accept the default values for the name and parameters, and you should uncheck the box that indicates if the data should be retrieved at startup. It is very important that the names of the data connections match the names of the method calls.
3. Add Activation Message Templates to Resources. When sending an activation message to start an activity flow, a "template" or default instance is used to create the initial message before adding your activation content. You must add these files to your InfoPath solution as resource files. Use the BizTalk developer tools in Visual Studio.Net to create an instance of the activation message for the action(s) you are enabling. In each instance, edit the instance document so that there is only one payload element, then validate this instance against the schema to make sure you have a valid starting point. This is a very important step because the BizTalk tools do not always generate an instance that is valid. 4. Enable hwsWorkflow and hwsAdapters within Manifest.xsf. In order to get your InfoPath solution working with HWS, you need to extract the form files and edit the manifest to include information about the available actions and tasks, and to configure the adapters to submit the appropriate messages to HWS. This takes the form of two sections within the manifest: hwsWorkflow and dataAdapters. Listing 1 shows the hwsWorkflow section. In this section you define whether the workflow task pane is going to be visible, the URL of the HWS service, and the allowable actions and tasks for this InfoPath solution. Notice that for each action an actionTypeID is required. This value can be looked up in the HWS_Actions table of the HWS database. Notice also that you can indicate which actions are available to initiate the workflow and which actions must come as later steps by using the canInitiateWorkflow attribute of the action. The next section is the data adapters section, which provides an adapter for each submission you need to trigger. The sample in Listing 2 shows one adapter used to initiate the workflow. Notice that the hwsOperation element has a type attribute that maps to the name of a method on the HWS service, and a typeID attribute which is the ID of one of the allowed actions for this solution, in this case the Assign action. In this sample we are adding an action to the activity flow, which is the first step after getting a new activity flow ID (which InfoPath handles for us). Also notice that we have identified the activation.xml instance that we created earlier for our HWS activation message, and that we then use the partFragment element to provide the mappings from our InfoPath document into that activation message. 5. Enable script actions for the workflow pane. The workflow task pane contains buttons that initiate the configured actions. In order for these buttons to operate correctly, you must write script that handles the click events and submits the appropriate adapters. For example, the adapter in the previous listing was named Assign. We need a script handler for the Assign button, which will be created in the workflow task pane for us, that will trigger this adapter to submit. The listing below shows this simple script. function Assign::OnClick(eventObj) You need a script block such as this for each dataAdapter element you include in the manifest. How It All Works, and What You Have to Tweak It is important to understand that when you are working with InfoPath in this way, the HWS messages are really acting as carriers of your form. You'll need to populate some of the necessary fields for the task messages and activation messages to indicate the status of your workflow, but you are really focused on doing so to move your InfoPath form around. With that said, it is important for the Payload element of messages to be mapped properly from activation messages to task messages; otherwise, your InfoPath form gets lost. Likewise, when a task message gets sent, what you really want sent is the InfoPath form, and not the task message XML. To accomplish this, you need a send pipeline with a component in it that can appropriately pull out your InfoPath form from the Payload and send that as the outbound message (there is sample of this in the source code for the article). Finally, the last key component that makes this all work is the processing instructions. These are the statements at the top of an InfoPath XML document that provide information on how to process the document. InfoPath uses these instructions to identity that a particular XML document is an InfoPath form, as opposed to just an XML document. In addition, for workflow there is a special processing instruction that provides valuable identifiers for the workflow and current step. An example of this processing instruction is shown below. <?mso-infoPathHWSWorkflow In the sample code, this processing instruction is created in the pipeline component before the form is sent out. It is necessary to provide this information so the InfoPath code can properly respond to HWS when new actions are taken. Conclusion MICROSOFT .NET LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
||||||||||||||||||||||||||||||||||