Microsoft BizTalk Server 2000
The new Microsoft BizTalk Server 2000 provides powerful tools for the exchange of information between businesses. The tools included with BizTalk Server 2000 allow you to create BizTalk schemas, to map fields and records from one specification to another, and to move data from one corporation to another using XML. These tools are based on the XML technology and standard and provide the data translation for an application-integration server. You can visit the Microsoft BizTalk Server 2000 Web site at http://www.microsoft.com/biztalkserver/ to download the BizTalk Server 2000 Technology Preview. The site includes instructions on how to install and set up a BizTalk server.
The five main tools in BizTalk Server are BizTalk Editor, BizTalk Mapper, BizTalk Management Desk, BizTalk Server Administration Console, and BizTalk Server Tracking. These tools can provide you with the ability to receive and send documents in a variety of formats, validate and create documents, work with multiple protocols, and ensure document delivery. In this tutorial, we will discuss the tools of BizTalk Server 2000.
The BizTalk Editor allows you to edit BizTalk documents and schemas. Using the BizTalk Editor, you can import existing document definitions, including DTDs, BizTalk schemas, electronic data interchange (EDI) specifications such as American National Standards Institute (ANSI) X12 and electronic data interchange for administration, commerce, and transport (EDIFACT), flat files, well-formed XML, structured document formats, and XML-based templates. You can also create new specifications from blank templates. A specification is a structured document that tells BizTalk Server 2000 how to format data. All specifications are stored as XML. Let's take a look at how the BizTalk Editor works.
If you have installed BizTalk Server 2000, click the Start button, point to Programs, Microsoft BizTalk Server 2000, and then choose BizTalk Editor to open the BizTalk Editor. We will work with the Northwind.biz document we created in Chapter 9 to see how to use the BizTalk Editor to edit this document. First take the following code in the Northwind.biz document and save it as Categories.xml (we have removed the customer element because the BizTalk Editor currently imports only one component at a time):
<Schema name = "NorthwindSchema"
xmlns = "urn:schemas-microsoft-com:xml-data"
xmlns:dt = "urn:schemas-microsoft-com:datatypes">
<ElementType name = "Categories"
xmlns:Categories = "urn:northwindtraders.com.Categories"
content="eltOnly" model="closed">
<group order = "seq">
<element type = "Categories.CategoryID"
minOccurs = "1" maxOccurs = "1" />
<element type = "Categories.CategoryName"
minOccurs = "1" maxOccurs = "1" />
<element type = "Categories.Description"
minOccurs = "0" maxOccurs = "1" />
<element type = "Categories.Picture"
minOccurs = "0" maxOccurs = "1"/>
</group>
</ElementType>
<ElementType name = "Categories.CategoryID"
xmlns:Categories = "urn:northwindtraders.com.Categories"
dt:type = "int">
<description>
Number automatically assigned to a new category
</description>
</ElementType>
<ElementType name = "Categories.CategoryName"
xmlns:Categories = "urn:northwindtraders.com.Categories"
dt:type = "string">
<description>Name of food category</description>
</ElementType>
<ElementType name = "Categories.Description"
xmlns:Categories = "urn:northwindtraders.com.Categories"
dt:type = "string"/>
<ElementType name = "Categories.Picture"
xmlns:Categories="urn:northwindtraders.com.Categories"
dt:type = "bin.base64">
<description>
Picture representing the food category
</description>
</ElementType>
</Schema>
|
To import a well-formed XML document, a DTD, or a BizTalk schema, from the Tools menu choose Import. The Select Import Module screen will appear as shown in Figure 16-1.
Figure 16-1. The Select Import Module screen.
Since we are working with a BizTalk schema, choose XML-Data Schema and then select the Categories.xml file. At this point, a dialog box will appear informing you that group elements are not supported; just click OK. The records and fields of the imported schema will appear in the BizTalk Editor specification tree, as shown in Figure 16-2.
Figure 16-2. Imported schema in BizTalk Editor.
As you can see, the BizTalk Editor has imported most of the information, such as the elements and their child elements and the values of these elements. However, it did not import the data types. You will need to add the data types. For the CategoryID element, click on the right column next to Data Type and a list box will appear. Select integer[int] from the drop-down list. Add the data types for the other elements.
The BizTalk Editor uses records and fields to present a document structure. Records and fields represent two types of components found in electronic data interchange (EDI) documents: segments and elements. A field corresponds to an EDI element and a record corresponds to an EDI segment. In regards to XML, we can think of a field as an element that either contains text or has no content at all, and a record as an element that can contain text, content, or other elements. As you can see in Figure 16-2, the root node was a record that contained four fields. The BizTalk Editor interprets the data contained in the records and fields of a document specification and creates a specification that is an XML representation of the document.
In Figure 16-2, you can also see that the BizTalk Editor has five tabs: Declaration, Reference, Parse, Dictionary, and Code List. Let's examine these tabs in more detail.
The Declaration tab can be used to set declaration property values, add a custom declaration, and delete a custom declaration.The properties listed in the Declaration tab are shown in the following table:
Declaration Tab Properties
| Property | Description |
|---|---|
| Name | Name of the element. |
| Description | Description of the element. This property can be used as a comment. |
| Data Type | Data type of the element. |
| Model | Can be closed or open. If the model is closed, the structure of a document that uses the specification currently being defined in the BizTalk Editor must conform to this specification. If the model is open, a document that uses this specification does not have to conform to this specification. |
| Type | Determines whether this component is an attribute or an element. For the root node, it can only be an element. |
| Content | Defines the type of content for an element. The root node and any record with child elements are Element Only, which means they can contain only elements. All other records can be either Empty or Text Only. If an element is empty, it contains no content. |
| MinLength, MaxLength | Used for fields or records that contain string content. These properties define the length of the field. |
The Reference tab can be used to set reference property values. It provides properties for each BizTalk Editor component. The properties of the root node, records that are not the root, and fields are all different from each other for the Reference tab. The available Reference tab properties for the root node are shown in the following table:
Reference Tab Properties for the Root Node
| Property | Description |
|---|---|
| Schema Name | Name of this particular specification. |
| Standard | Name of an industry standard, such as XML, X12, or EDIFACT, that was used to create this standard (if one exists). |
| Standards Version | Version of the standard (if a standard was used). |
| Document Type | The document type of the specification (if a specification was used). |
| Version | Version number of the specification. |
| Default Record Delimiter | Determines which character you want to use to delimit records. You can use different characters for different records. This only applies to non-EDI standards. |
| Default Field Delimiter | Determines which character you want to use to delimit fields. You can use different characters for different fields. This only applies to non-EDI standards. |
| Default Subfield Delimiter | Determines which character you want to use to delimit child fields. You can use different characters for different fields. This applies only to non-EDI standards. |
| Default Escape Character | Can be set to Tab (0x9), LF (0xa) and CR (0xd). This applies only to non-EDI standards. |
| Unicode | If you set this property to Yes, the data associated with this specification uses the Unicode character set. If you don't specify the value for this property, it works with both Unicode and non-Unicode data. If you set this property to No, the data cannot be Unicode. If you are working with ASCII data, you must set this property to No. |
| Receipt | If this property is set to Yes, you'll receive an interchange receipt acknowledgement, which will tell you that the message arrived at its destination. If this property is set to No, the documents built from this specification will be validated, but no receipt will be delivered if the message is received. |
| Envelope | If this specification belongs to an interchange specification, choose Yes; otherwise choose No. |
| Target Namespace | If you are working with a BizTalk framework document that uses a namespace, you must list the namespace here. |
Reference Tab Properties for Records
| Property | Description |
|---|---|
| Min Occurs | Minimum number of times that a record can occur. The value can be either 0 or 1. |
| Max Occurs | Maximum number of times a record can occur. The value can be either 1 or *. If you use either a star or don't specify a value for this property, BizTalk Mapper will define this record as a loop, if the specification is used in BizTalk Mapper. |
Reference Tab Properties for Fields
| Property | Description |
|---|---|
| Required | If the field is required, set this property to Yes. |
| Start Position | If the property is positional (contains a position in the record where a field starts), a number that indicates the starting position of the field in the record. |
| End Position | If the property is positional, a number that indicates the ending position of the field in the record. |
Figure 16-3 shows the Reference tab for the root node.
Figure 16-3. The BizTalk Editor showing the Reference tab properties for the root node.
Notice in the figure that we are missing the namespace that we had originally included. Add the following namespace to the root node Target Namespace property on the Reference tab: urn:northwindtraders.com.Categories.
The Parse tab is used to determine how the fields are defined in a document that uses the specification created by the BizTalk Editor. The Parse tab is used for documents that are delimited in some way, such as a comma delimited text file. The actual properties that are available will depend on whether you are working with a field or record and on the standard (such as X12, EDIFACT, or XML) and Structure property on the Parse tab you are using. If you have chosen to use XML as your standard, no properties will be available in the Parse tab. Because the schema we imported earlier used an XML specification, we cannot see or set any values of the Parse tab properties using the BizTalk Editor. If you choose either the X12 or EDIFACT standard, you will be able to set up properties for the Parse tab with delimited documents.
Parse Tab Properties for Root Nodes and Records
| Property | Description |
|---|---|
| Structure | Can be delimited or positional. If left blank, the file is considered to be delimited. |
| Source Tag Identifier | Name of the source tag that is used to match the record with the data. |
| Source Tag Position | Used in positional records; indicates the beginning of the tag. |
| Field Order | Either Prefix (a delimiter is placed before each component, for example, *aa *bb *cc), Postfix (a delimiter is placed after each component, for example, aa* bb* cc*), Infix (a delimiter is placed between components, for example, aa*bb*cc), or Blank (unknown order). This property is used only for delimited records. |
| Delimiter Type | Can be set to Character (the actual character to use as the delimiter is defined in the Delimiter Value property), Inherit Record (use the delimiter designation of the previous record), Inherit Field (use the delimiter designation of the previous field), or Inherit Subfield (use the delimiter designation of the previous subfield). This property is used only for delimited records. |
| Delimiter Value | The character that is used to delimit the text if the value of the Delimiter Type property is Character. This property is used only for delimited records. |
| Escape Type | Can be Character (tells the parser to suspend the delimiter designation if this character is found in the document; the character is specified in the Escape Value property), or Inherit Escape (for inheriting the previous record's escape type). |
| Escape Value | If the value of the Escape Type property is Character, this property specifies the escape character. |
| Append New Line | If set to Yes, indicates that when the record delimiter is found, begin the next record on a new line. If set to No, all records are on the same line. |
| Skip Carriage Return | If set to Yes, the parser will skip the carriage return (CR) value after a delimiter. |
| Skip Line Feed | If set to Yes, the parser will skip the line feed (LF) value after a delimiter. |
| Ignore Record Count | If set to Yes, tells the parser not to count any CR or LF values when counting characters. |
Parse Tab Properties for Fields
| Property | Description |
|---|---|
| Custom Data Type | Used for specifications that are based on an X12 or EDIFACT standard. Only applies to if the structure type is delimited. |
| Custom Date/Time Format | Used for specifications that are based on an X12 or EDIFACT standard. Only applies to if the structure type is delimited. |
| Justification | For positional and delimited files. If set to Left, the data that is less than the maximum length is aligned left. If set to Right, the data is aligned right. |
| Pad Character | A character that will be used to pad blank spaces in a field. |
BizTalk Mapper allows you to map fields and records from one specification to fields and records in another specification. BizTalk Mapper uses links and functoids. A link is a simple copy operation from the value in one field to the value in another field. A link can also copy to a functoid. A functoid is an object that allows for complex structural manipulation operations between source elements and destination elements. Before a specification can be used in BizTalk Mapper, it needs to be defined in the BizTalk Editor. BizTalk Mapper supports EDI, flat files, XML files, schemas, and even ADO recordsets. BizTalk Mapper can also create XSL style sheets for mapping.
As an example of how to use BizTalk Mapper, we will use two PO specifications that come with BizTalk Server 2000. To see how BizTalk Mapper works, follow these steps:
- Click the Start button, point to Programs, Microsoft BizTalk Server 2000, and then choose BizTalk Mapper.
- From the File menu, choose New. You will see the Select Source Specification Type screen where you can choose either Local Files, which is a specification on your local computer or network; Templates, which are templates that came with BizTalk Server; or WebDav (Web Distributed Authoring and Versioning) Files, which refers to specifications on shared servers. For our example, we will imagine that we are transferring a purchase order file from a local XML file to an XML purchase order file located in a common WebDav location.
- In the Select Source Specification Type screen, click Templates, choose XML, and then choose CommonPO.xml. You will now see the Select Destination Specification Type screen.
- For the destination, choose WebDav Files. The Retrieve Destination Specification screen will appear. In this screen choose Microsoft, and then choose CommonPO.xml. In this case, both specifications use fields with the same name. In other cases, the fields might have completely different names.
- Expand the POHeader on both the source specification and destination specification. You can see the fields contained in the POHeader. Drag the Purpose field from the source to the destination. The map should now look as shown in Figure 16-4.
By connecting source and destination fields, you can create a map between a source and a destination specification. If you now connect other fields, you can go to the Tools menu and choose Compile Map to produce XSL code that will create the transformation between the two specifications. Figure 16-5 shows the XSL code generated in the Output tab on the bottom of the BizTalk Mapper after linking several other fields and then compiling.
Figure 16-4. Microsoft BizTalk Mapper.
Figure 16-5. The Output tab showing the XSL code after compiling.
As mentioned, you can use functoids to perform complex structural transformations between source elements and destination elements. Functoids use predefined formulas and specific values to perform calculations. You can select functoids from the Functoid Palette. To work with functoids, follow these steps:
- On the View menu, choose Functoid Palette to open the Functoid Palette screen.
- From the Functoid Palette screen, you can choose a functoid and drag it to the mapping grid area. The mapping grid area is the gray grid area between the source and destination in Microsoft BizTalk Mapper. As an example, select the Mathematical tab of the Functoid Palette screen, click the X (multiplication) functoid, and drag the X onto the grid. Connect a field to the functoid, right click the functoid, and then select Properties to open the Functoid Properties window. In this window, select the Script tab. You can see that a function is created in this tab, as shown in Figure 16-6.
Figure 16-6. The Script tab in the Functoid Properties window.
In our case, the function FctMathMultiply1 is defined in the following code:
Function FctMathMultiply1( p_strParm0 ) If ( IsNumeric( p_strParm0 ) ) Then FctMathMultiply1 = CStr ( CDbl( p_strParm0 ) ) Else FctMathMultiply1 = "" End If End Function |
As you can see, the function is just a template. You will need to fill in the necessary functionality to make this function work. In the pre-release version of the BizTalk Mapper, this script cannot be edited in the Functoid Properties window. However, you can go to the Advanced tab of the Functoid Palette to edit the script. (You might need to scroll over to see the Advanced tab.) Get the Custom Visual Basic Script from the Advanced tab and drop it on the grid, make a connection from a field in the source document to a field in the destination document, and then edit the script. A custom transformation will be created between the source field and the destination field.
As you can see, functoids make it easy to do transformations. When the map is compiled by choosing Compile Map from the Tools menu, the XSL script will include functions to perform these transformations.
The BizTalk Management Desk is used to create, establish, and maintain relationships within a corporation and between a corporation and its partners. These relationships are built on agreements, which are rules that determine how information is exchanged. Each agreement has a source organization and a destination organization, or an internal organization and one of its applications. The first step in creating an agreement is designating a default organization, which can be either the source or the destination for every agreement. Applications can also be either the source or the destination, but not both. If an application is used, it must be part of the default organization. There must be at least one document definition defining which documents the source can send to the destination. An open agreement means that either the receiver or the sender, but not both, are open. An open-source agreement always has the designated default organization as its destination organization; an open-destination agreement always has the designated default organization as its source organization.
An agreement defines the movement of information in one direction. If the default organization is the source, it is an outbound agreement. If the default organization is the destination, it is an inbound agreement. Outbound agreements oversee the movement of information out of BizTalk Server 2000, and inbound agreements control the movement of information into BizTalk Server 2000.
In this section, we are going to look at how BizTalk Management Desk works. Follow these steps:
- Click the Start button, point to Programs, Microsoft BizTalk Server 2000, and then choose Microsoft BizTalk Management Desk. You will see a Help window displayed that describes the steps you need to take in order to move information between corporations. The first time you use the BizTalk Management Desk, you'll need to select a default organization.
- In the upper right corner, click the Select button in the Default Organization box. This will bring up the Select An Organization screen. If you do not have an organization yet, click New. This will bring up the Organization Editor. For this example, we'll create an organization for Northwind Traders Corporation.
- In the General Tab, type Northwind Traders for the Organization Name in the Organization Identifiers section. In the Identifiers tab you will see that there already is a default Organization identifier named Organization. All organizations get this default, do not delete or change it. You can create as many identifiers as you want, but if you are using an X12 format, you should create a two-character identifier as the default.
- To create a new identifier, type NWT in the Value field of the Identifier tab, and check Set As Default.
- Click Refresh to add the new value to the list of identifiers.
NOTE
BizTalk Management Desk also allows you to create custom names with a qualifier and to associate applications with the default organizations, but we will not go into this in this example. Refer to the Microsoft BizTalk Server 2000 Help file for the detailed information.
- Click OK in the Organization Editor, and then click OK in the Select An Organization box. You should see Northwind Traders listed as the default organization.
- The next step is to create an agreement. On the File menu click New, and then click Agreement. This will bring up the Agreement Editor. We will make this a movement of information within the Northwind Traders Corporation from its central location to its European location.
- Type Northwind Traders Europe in the Agreement Name field in the Agreement Editor.
- Click the Destination icon. This will bring up the Select An Organization screen again.
- Click New, and create an organization called Northwind Traders Europe. In the Identifiers tab, give it a value of NWTE, and set this as the default. Once you have created Northwind Traders Europe, select it as the destination.
Now that we've created the agreement , the next step will be to create a document definition. A document definition provides a reference to a specification, which can be created using BizTalk Editor. The outbound and inbound documents will both be associated with a document definition. A pipeline connects the document definition of an outbound document with the document definition of an inbound document. Pipelines are defined in agreements and distribution lists.
You can use the predefined document definitions, or you can use a specification, such as one that is created with BizTalk Editor, to create a new definition. To create a new definition, from the View menu, choose Document Definitions. This will open the Document Definitions Viewer. You can use any specification that is published to a server. For this example, click New to display the Document Definition Editor screen. Click Browse in the Document Definition Editor screen, choose Microsoft, and then choose Common PO.xml in the local server. Type CommonPO.xml in the Document Definition Name field. You can select the Tracking tab if you want to log any of the fields. You can add two of the following types of fields to log: integer, real, date, and text. You can select multiple fields as a custom data type. These fields will become an XML concatenated string. You can only track fields that have a data type specified. You can use the information that is logged to perform tracking of certain business operations. The quantity field for a particular item or the total for purchase orders are two examples of fields that you might want to track and could use to perform an analysis of various business processes.
You can also add selection criteria in the Document Definition Editor. BizTalk Server 2000 determines what document definition to associate a document with by getting information from the document. For X12 and EDIFACT documents, it is not possible to obtain this information from the document. Thus, the information concerning which document definition to use must be placed in the functional group header of the X12 or EDIFACT document. The selection criteria is used to uniquely identify the document definition when processing an inbound EDI document. The selection criteria can also be used to create functional group header information for outbound EDI document envelopes. When working with X12 and EDIFACT, you'll need to add the following selection criteria: application_sender_code, application_receiver_code, and functional_identifier. The X12 format will also need the standards_version selection criteria, and the EDIFACT will need the standards_version_type and the standards_version_value selection criteria. We will not add any selection criteria for tracking, therefore just click OK in the Document Definition Editor and then click Close on the Document Definition Viewer. Next, go to the Agreement Editor and click on the Document Definition icon. This will bring up the Select Document Definition screen. Click on the CommonPO.xml file that you just selected and then click Add. Click OK. You should now see that the text below the Document Definition icon reads Complete.
You will now need to select a Transport method. Click on the Transport icon. This will bring up the Transport screen. In this screen, select a transport type. For this example, select HTTP. For the Address field, type http://localhost, where localhost is the name of your local server. Then click OK to close the Transport screen.
At this point, we have completed all the required steps for creating agreements. There are some optional things we can do. We can create an envelope that creates headers and sometimes footers for the document. BizTalk Server 2000 currently supports Custom XML, ANSI X12, UN/EDIFACT and flat file (either delimited or positional) envelope formats. You can also create your own custom envelope formats.
We will not create an envelope or set security properties in this example, so you can now click Save in the Agreement Editor to open the Save As screen. Click Save Agreement as Complete and then click OK. In the BizTalk Management Desk you can see that this is an outbound agreement because the default organization is the sender.
Now let's create an inbound agreement:
- On the File menu, click New, and then choose Agreement. This will bring up the Agreement Editor. Name the agreement Internal Order.
- Click the Source icon to open the Select An Organization screen. In this screen, click New to open the Organization Editor.
- In the Organization Editor, type Northwind Traders Order Dept for the Organization Name field.
- Click the Identifiers tab, type NWTOD for the value, and then click Set As Default. Click Refresh, and then click OK in the Organization Editor. Close the Select An Organization screen.
- In the Agreement Editor, click the Source icon to open the Select An Organization screen. In this screen, choose the Northwind Traders Order Dept and then click OK.
- Click the Document Definition icon to open the Select Document Definition screen. In this screen, choose CommonPO.xml and then click OK.
- Click the Transport icon, choose HTTP for the Transport Type field, and then type http://localhost. The destination should be Northwind Traders.
- Click Save to open the Save As screen. Choose the Save Agreement As Complete option. You should now see that this agreement is listed as an inbound agreement in the BizTalk Management Desk.
Pipelines connect an inbound agreement to an outbound agreement. For example, you could have an inbound agreement created from an order application that takes orders and sends them to BizTalk Server 2000. Once they arrive on BizTalk Server 2000, an outbound agreement is used to send these orders to a distributor. The connection of the inbound and outbound agreements creates a pipeline.
To create a pipeline, you must always select the outbound agreement first. Click on the Northwind Traders Europe Outbound agreement. On the File menu, choose New, and then choose Pipeline. The Pipeline Editor opens in the lower-right pane of the BizTalk Management Desk. In this example, orders will be sent from the Internal Orders department to BizTalk Server 2000 and then forwarded to the European offices. We will use the two agreements we have created to do this.
In the Pipeline Editor, type PO Pipeline as the pipeline name. Click the Inbound Agreement icon to open the Select An Inbound Agreement screen. Choose Northwind Internal, and then choose CommonPO.xml as the inbound and outbound document definitions. Click Save. To view the pipeline you have created, go to the View menu and choose Pipeline. This will open the Pipeline Viewer, where you can view the available pipelines.
discuss this topic to forum
