Functoid Design

In this section, we will design a custom functoid that we will implement in the next section. To this point, the discussion has centered on architecture of the BizTalk channel and example scenarios for functoids. The important take-home points were that a functoid operates within a BizTalk channel to provide custom business logic in transforming business data. This transformation plays a key role in bridging between public and private interfaces.

A functoid is relatively easy to design and requires two main specifications:

  • Functionality— Interface with data elements in channel's map and provide the desired computation

  • BizTalk Mapper integration— User interface images and classification

Functionality

A functoid is a single function though which the COM interface IFunctoid implements one or more functoids. Each functoid accepts input parameters and must have a return value. The number of input parameters can be variable. There are no output parameters. All input parameters and the return value must be a simple type insertable into XML such as a string, number, or boolean.

The first step is deciding the function signature. As designers, we must avoid the usual practice of placing the burden of constructing the inputs on the caller. It must be possible for the user to drag the function input directly from the XML data or from the output of another functoid. There is a limited capability to format or calculate input parameters.

For a general-purpose functoid, such as a formatter, the function signature is largely independent of the XML format in the channel. For a business-specific functoid, such as a classifier, the function signature might need to account for the XML schema for the data inside the channel.

Example: Selector, a General-Purpose Functoid

The functoid Selector is similar to the C++ operator ?: and the VB iif function. The similarity is that you can write a single expression that will evaluate to one of n subexpressions based on a single value, termed the selector.

Example usage:

Selector(true, "A", "B") returns "A" 
Selector(false, "A", "B") returns "B"
Selector(1, "A", "B", "C", "D") returns "A"
Selector(4, "A", "B", "C", "D") returns "D"

In general, there are n+1 arguments, for n >= 0. The first argument, the selector, is a boolean value or an integer index. The last n arguments are a list of possible return values. The first argument can be a nonintegral number, in which case the floor of the number is used. The first argument can be a string representation of a number.

Selector( s, v1, ..., vn ) 
        = v1 if s = true or "true" (case insensitive)
        = v2 if s = false or "false" (case insensitive)
        = vs if s is an integer and 1 <= s <= n
        = empty string "", otherwise

Example: TradeClassifier, a Business-Specific Functoid

A functoid TradeClassifier expects data specific to a FIX message. It accepts a set of data items from the trade data and returns a classification “A”, “B”, “C”, or “D”. The meaning of these classification levels is specific to an internal business process. We do not get more descriptive here to retain the focus on the mechanism rather than the financial trade example. If it helps, substitute meaningful category names.

We will not actually implement this functoid. The Selector functoid will suffice for showing the coding techniques.

BizTalk Mapper Integration

Integration with the BizTalk Mapper tool requires an icon, a display name, ToolTips, a tab on which to place the functoid, and a set of constraints for connecting the functoid to other diagram elements.

To integrate seamlessly, exercise care to match the icon design and naming conventions. Table 18.2 provides the list of tabs from the Functoid Palette with a sample item from each. Each tab has a single color for the icon background. The one exception is the Advanced tab. Icons are 16×16 pixels, though no guidelines are documented for the number of colors.

Table 18.2. BizTalk Mapper Functoid Tabs with Sample Items
TabIcon RGB ColorFunctoidToolTip
String(156,48,49)UppercaseConverts a text item to uppercase characters.
Mathematical(49,154,156)MultiplicationMultiplies one number by another number.
Logical(0,130,0)Logical ORReturns the logical OR of parameters.
Date/Time(0,0,156)TimeReturns the current time.
Conversion(156,0,156)HexadecimalReturns a hexadecimal value when given a decimal number.
Scientific(99,101,0)CosineReturns the cosine of a number.
Cumulative(255,48,99)Cumulative SumSums all values for the connected field by iterating over its parent record.
Database(0,101,255)Database LookupSearches a database for a specific value, retrieves the record that contains the value, and stores it in an ADO record set.
Advanced(206,154,0)ScriptingEnables customized functionality based on a script that you provide.
 (132,0,132)LoopingCreates multiple output records by iterating over each input record.

The number and names of tabs are fixed. Note that BizTalk 2002 recommends that no custom functoids be added to the Database tab. Use the Advanced tab for any new database-related functoids.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset