HomeBrainDump Microsoft BizTalk Server 2004: Creating a ...
Microsoft BizTalk Server 2004: Creating a Schema Map
Building on Microsoft Windows Server System and the Microsoft .NET Framework, Microsoft BizTalk Server 2004 delivers an integrated, interoperable, modularized, extensible, and security-enhanced e-business solution that enables companies to connect information, systems, people, and processes. The labs in this series build upon each other to give a "top to bottom" experience of Microsoft BizTalk Server 2004. This lab you will create a schema map, add functoids to the map, and finally validate the map.
Microsoft BizTalk Server 2004: Creating a Schema Map
Objectives
After completing this lab, you will be able to:
Create a schema map by using BizTalk Mapper.
Add functoids to a map.
Validate a map.
Build a schema map project.
Scenario
As part of a B2B process, Northwind Traders needs to send orders to a supplier named Fabrikam. Northwind Traders uses a file format for customer orders that is different from the purchase order format that Fabrikam requires. Because of this, you must create a schema map to transform Northwind Traders’ customer order schema format to the purchase order schema format required by Fabrikam.
In this lab, you will create a schema map to associate specific fields in a customer order (the source schema) to corresponding fields in Fabrikam’s purchase orders (the destination schema).
You will then add functoids to the map in order to perform special transforms between fields in the source schema and destination schema. Finally, you will validate the map, and then build the project to compile the map and associated schemas and to confirm that there are no errors in the project.
To actually complete this lab you can sign up for for free. It's simple — no complex setup or installation is required to try out BizTalk running in the full-featured MSDN Virtual Lab. As part of the MSDN Virtual Lab, you will have full access to BizTalk to complete the lab by going Here.
In this exercise, you will use BizTalk Mapper to create a map. This map will be used to create links that associate the data fields between two different schemas.
Tasks
Detailed steps
Set up lab.
Click inside the virtual machine window.
Press Right-ALT + DEL.
Type a password of pass@word1 and press Enter.
Click Start |Windows Explorer and navigate to C:\Labs\Setup Scripts\SetupLab3.A.bat.
Double-click the file to run it and close Windows Explorer.
This script will erase the existing projects and artifacts in the C:\Labs\Work folder and copy all required artifacts and files for this lab into the C:\Labs\Work folder.
Open an existing solution.
This opens a project with predefined schemas (.xsd).
Click Start | All Programs | Microsoft Visual Studio .NET 2003 | Microsoft Visual Studio .NET 2003.
On the File menu, click Open Solution.
In the Open Solution dialog box, navigate to C:\Labs\Work\NWBusinessSolution, select NWBusinessSolution.sln, and then click Open.
A project opens in Solution Explorer.
Add the destination schema to the project.
This loads the schema for the purchase order format used by Fabrikam, Inc.
In Solution Explorer, right-click the NWMessaging project, and then click Add Reference.
In the Add Reference dialog box, click Browse, navigate to C:\Labs\SupportingArtifacts\FKMessaging \bin\Development, select FKMessaging.dll, and then click Open.
Click OK.
The FKMessaging reference is added to Solution Explorer.
Create the BizTalk map.
Selecting the Map template causes BizTalk Mapper to start.
In Solution Explorer, right-click the NWMessaging project, point to Add, and then select Add New Item.
In the Add New Item dialog box, in the Templates pane, click Map.
In the Name box, type NWCustomerOrder_To_FKSupplierPO.btm to name the map.
Click Open to start BizTalk Mapper.
BizTalk Mapper opens, and the new map is added to Solution Explorer.
Open the source and destination schemas.
This prepares the Mapper’s UI to translate the source schema to the destination schema.
Renaming the map page makes map management easier. It does not affect the XSLT in any way.
Below the Map Zone, right-click the Page 1 tab (at the bottom of the map), and click Rename Page.
Rename the page Data Maps and press Enter.
Create a link between fields.
Linking nodes in the Mapper creates XSLT that will transform the data in the source document into the structure of the destination document.
Using the pairings in the table below, in the Source Schema pane, click each source field and then drag it across the Mapper grid to the associated destination field in the Destination Schema pane.
Source Field
Destination Field
CustomerPONumber
PONumber
UnitPrice
Cost (under items)
Quantity (under lines)
Qty
ItemID
ProdID
Status
Status
The lines in BizTalk Mapper show how the fields between schemas have been mapped, as shown here:
In this exercise, you will add functoids to transform a value from a field in the source schema to a field in the destination schema.
Tasks
Detailed steps
Add a cumulative functoid to the map.
This functoid calculates the total quantity of all line items in the customer order before updating the total quantity in the purchase order.
In the Toolbox, click the Cumulative Functoids palette, click the Cumulative Sum functoid, and then drag it to the Mapper grid.
In the Source Schema pane, click the Quantity field, and then drag a link to the Cumulative Sum functoid in the Mapper grid.
In the Mapper grid, click the Cumulative Sum functoid, and then drag a link to the TotalQty in the Destination Schema pane.
Add a multiplication functoid to the map.
This functoid calculates the total cost of a line item.
In the Toolbox, click the MathematicalFunctoids palette, click the Multiplication functoid, and then drag it to the Mapper grid.
In the Source Schema pane, click the UnitPrice field, and then drag a link to the Multiplication functoid in the Mapper grid.
In the Source Schema pane, click the Quantity field, and then drag a link to the Multiplication functoid in the Mapper grid.
Add another cumulative functoid to the map.
This functoid calculates the total cost of all line items in the customer order before updating the total cost in the purchase order.
In the Toolbox, click the Cumulative Functoids palette, click the Cumulative Sum functoid, and then drag it to the Mapper grid.
Make sure to place this functoid to the right of the multiplication functoid. Functoids must always link from left to right.
In the Mapper grid, drag a link from the Multiplication functoid to the Cumulative Sum functoid in the Mapper grid.
In the Mapper grid, drag a link from the Cumulative Sum functoid to the TotalCost field in the Destination Schema pane.
Add a scripting functoid to a map.
This step changes the value in the Priority field from an integer to a string. This function could be written in C#, Jscript.NET, XSLT, or an external assembly.
In the Toolbox, click the Advanced Functoids palette, select the Scripting functoid, and then drag it to the Mapper grid.
In the Source Schema pane, click the Priority field, and then drag a link to the Scripting functoid in the Mapper grid.
Click the Scripting functoid, and then drag a link to the Priority field in the Destination Schema pane.
Select the Scripting functoid, and press F4 (this brings up the Functoid Properties window).
Select the Script property, and then click the ellipsis(…) button.
In the Configure Functoid Script dialog box, in the Script type drop-down list, select Inline Visual Basic .NET, and then type the following code in the Inline scriptbuffer text box:
Public Function PriorityConversion(ByVal param1 As String) As String Select param1 Case “1” Return “High” Case “2” Return “Medium” Case “3” Return “Low” Case Else Return “Error” End Select End Function
Click OK to save the script and close the Functoid Properties window.
The completed map should look similar to this:
Create a new map page.
It is not required to create a new page but it will aid in readability.
Below the Map Zone, right-click the Data Maps tab, click Add Page to create a new page (or map zone), and then rename the page as Control.
Add a Looping functoid to the map.
This functoid loops through all occurrences of line items in the customer order and creates multiple line items in the purchase order.
If no Looping functoid is present, the Mapper will try to determine how many of the destination nodes to create for each occurrence of the source node. Even if the Mapper chooses the looping that you desire, it is best for documentation purposes to explicitly use the Looping functoid.
In the Toolbox, click the AdvancedFunctoids palette, and then drag the Looping functoid to the Mapper grid on the Control page.
In the Source Schema pane, click the SalesOrderLine record, and then drag it to Looping functoid in the Mapper grid.
In the Mapper grid, drag a link from the Looping functoid to the Item record in the Destination Schema pane.
In this exercise, you will use the Validate Map command to determine whether the map contains any internal inconsistencies, or has other issues that might prevent it from being used effectively for mapping schemas.
Tasks
Detailed steps
Validate the map.
This makes sure that the map could produce a valid destination document.
An example of an invalid map would be one in which a required field in the destination document is not filled.
In Solution Explorer, right-click NWCustomerOrder_To_FKSupplierPO.btm, and then select Validate Map.
The results of the map validation are displayed in the Output window.
Test the map.
Testing a map provides a way to catch exceptions or logical errors by using an actual instance document, without deploying an entire solution.
Right-click NWCustomerOrder_To_FKSupplierPO.btm, click Properties, and then configure the following properties:
Property
Value
TestMap Input Instance
C:\Labs\Work\CustomerOrder.xml
TestMap Input
XML
Click OK to save the map.
Right-click NWCustomerOrder_To_FKSupplierPO.btm, and then select Test Map.
A link to the XML instance is shown in the Output window. Click the link while pressing Ctrl to open the resulting XML file.
Exercise 4 Building the Schema Map Project
Scenario
In this exercise, you will build the project to generate an assembly that contains the resources (the schemas and the map) that you have created. This also ensures that that there are no compile-time errors in the work you have completed so far.
Tasks
Detailed steps
Build the project. The assembly is compiled into a DLL file and saved in the …\bin\Development folder within the project folder.
On the File menu, click Save All.
In Solution Explorer, right-click NWMessaging, and then select Build.
The results of the compiled project are displayed in the Output window.