Вы находитесь на странице: 1из 9

Microsoft Virtual Labs

Working with Maps


Working with Maps

Table of Contents
Working with Maps ...................................................................................................................... 1
Exercise 1 Creating a Schema Map using the BizTalk Mapper.....................................................................................2
Exercise 2 Adding Functoids to a Map..........................................................................................................................4
Exercise 3 Validating and Testing the Map...................................................................................................................6
Exercise 4 Building the Schema Map Project................................................................................................................7
Working with Maps

Working with Maps


After completing this lab, you will be better able to:
Objectives a. Create a schema map by using BizTalk Mapper.
b. Add functoids to a map.
c. Validate a map.
ƒ Build a schema map project.
As part of a business-to-business (B2B) process, Northwind Traders needs to
Scenario 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 Trader’s 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 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.

Estimated Time to 45 Minutes


Complete This Lab

Computer used in this Lab The password for the Administrator account on this computer is: pass@word1

Page 1 of 7
Working with Maps

Exercise 1
Creating a Schema Map using the BizTalk Mapper

Scenario
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


1. Configure the a. On the desktop double-click the SetupLab.bat shortcut.
starting lab b. From the Lab Setup Menu, type 3.
environment.
2. Open an existing a. Click Start | All Programs | Microsoft Visual Studio 2005 | Microsoft Visual
solution. Studio 2005.
This opens a project with b. On the File menu, point to Open | Project/Solution.
predefined schemas (.xsd).
c. In the Open Project dialog box, browse to
C:\Labs\Work\Lab03\NWBusinessSolution, click NWBusinessSolution.sln,
and click Open.
The existing project opens in Solution Explorer.
3. Add the destination a. In the Solution Explorer, right-click the NWMessaging project and click Add
schema to the Reference.
project. b. In the Add Reference dialog box, on the Browse tab, browse to
This loads the schema for the C:\Labs\SupportingArtifacts\FKMessaging\bin\Development, click
purchase order format used by FKMessaging.dll and click Add.
Fabrikam.
c. Click OK.
The FKMessaging reference is added to the Project.
4. Create the BizTalk a. In the Solution Explorer, right-click the NWMessaging project, point to Add and
map. click New Item.
Selecting the Map template b. In the Add New Item dialog box, in the Categories pane, click Map Files, and
causes BizTalk Mapper to start then in the Templates pane, click Map.
after the map is added to the
project. c. In the Name box, type NWCustomerOrder_To_FKSupplierPO.btm to name
the map.
d. Click Add to start BizTalk Mapper.
BizTalk Mapper opens and the new map is added to Solution Explorer.
5. Open the source and a. In the BizTalk Mapper, open the following schemas:
destination schemas. Source Schema Destination Schema
This prepares the Mapper’s UI to
translate the source schema to Schemas References
the destination schema. NWMessaging.CustomerOrder FKMessaging
Schemas
FKMessaging.SupplierPO
6. Rename the map a. Below the Map Zone, right-click the Page 1 tab (at the bottom of the map) and
page. rename the page Data Maps.
Renaming the map page makes
map management easier. It does
not affect the XSLT in any way.

Page 2 of 7
Working with Maps
Tasks Detailed Steps
7. Create a link a. Using the pairings in the table below, in the Source Schema pane, click each
between fields. source field and then drag it across the Mapper grid to the associated destination
Linking nodes in the Mapper field in the Destination Schema pane.
creates XSLT that will transform To expand all nodes in the schema right-click the <Schema> node, and then click
the data in the source document Expand Tree Node.
into the structure of the
destination document. Source Field Destination Field
CustomerPONumber PONumber
UnitPrice (under Lines | Cost
SalesOrderLine)
Quantity Qty
ItemID ProdID
Status Status

Page 3 of 7
Working with Maps

Exercise 2
Adding Functoids to a Map

Scenario
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


1. Add a cumulative a. If the Toolbox is not docked on the left side, on the View menu, click Toolbox.
functoid to the map. b. In the Toolbox, on the Cumulative Functoids palette, click the Cumulative Sum
This functoid calculates the total functoid and drag it to the Mapper grid.
quantity of all line items in the
customer order before updating c. In the Source Schema pane, click the Quantity field and drag a link to the
the total quantity in the purchase Cumulative Sum functoid in the Mapper grid.
order. d. In the Mapper grid, click the Cumulative Sum functoid and drag a link to
TotalQty in the Destination Schema pane.
2. Add a multiplication a. In the Toolbox, on the Mathematical Functoids palette, click the Multiplication
functoid to the map. functoid, and then drag it to the Mapper grid.
This functoid calculates the total b. In the Source Schema pane, click the UnitPrice field and drag a link to the
cost of a line item. Multiplication functoid in the Mapper grid.
c. In the Source Schema pane, click the Quantity field and drag a link to the
Multiplication functoid in the Mapper grid.
3. Add another a. In the Toolbox, on the Cumulative Functions palette, click the Cumulative Sum
cumulative functoid functoid and drag it to the Mapper grid.
to the map. Make sure to place this functoid to the right of the multiplication functoid. Functoids
This functoid calculates the total must always link from left to right.
cost of all line items in the
b. In the Mapper grid, drag a link from the Multiplication functoid to the
customer order before updating
the total cost in the purchase Cumulative Sum functoid in the Mapper grid.
order. c. In the Mapper grid, drag a link from the Cumulative Sum functoid to the
TotalCost field in the Destination Schema pane.
4. Add a scripting a. In the Toolbox, on the Advanced Functoids palette, click the Scripting functoid
functoid to a map. and drag it to the Mapper grid.
This step changes the value in b. In the Source Schema pane, click the Priority field and drag a link to the
the Priority field from an integer Scripting functoid in the Mapper grid.
to a string. This function could be
written in C#, Jscript .NET, c. Click the Scripting functoid and drag a link to the Priority field in the
XSLT, or an external assembly Destination Schema pane.
d. Right-click the Scripting functoid and click Properties.
e. Click the Script property and click the Ellipsis (…) button.
f. In the Configure Functoid Script dialog box, in the Script type list, choose
Inline Visual Basic .NET and copy the code from
C:\Labs\Work\Lab03\ScriptingFunctoid.txt to the Inline script buffer text box
(overwrite any code already present):
Public Function PriorityConversion(ByVal param1 As String)
_
As String
Select param1
Case “1”

Page 4 of 7
Working with Maps
Tasks Detailed Steps
Return “High”
Case “2”
Return “Medium”
Case “3”
Return “Low”
Case Else
Return “Error”
End Select
End Function
g. Click OK to save the script.
5. Create a new map a. Below the Map Zone, right-click the Data Maps tab, click Add Page to create a
page. new page (or map zone) and rename the page as Control.
You are not required to create a
new page, but it will aid in
readability.
6. Add a Looping a. In the Toolbox, on the Advanced Functoids palette, and then drag the Looping
functoid to the map. functoid to the Mapper grid on the Control page.
This functoid loops through all b. In the Source Schema pane, click the SalesOrderLine record and drag it to
occurrences of line items in the Looping functoid in the Mapper grid.
customer order and creates
multiple line items in the c. In the Mapper grid, drag a link from the Looping functoid to the Item record in
purchase order. the Destination Schema pane.
If no Looping functoid is present, d. On the File menu click Save All.
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.

Page 5 of 7
Working with Maps

Exercise 3
Validating and Testing the Map

Scenario
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


1. Validate the map. a. In the Solution Explorer, right-click
This makes sure that the map NWCustomerOrder_To_FKSupplierPO.btm and click Validate Map.
could produce a valid destination The results of the map validation are displayed in the Output window.
document.
An example of an invalid map
would be one in which a required
field in the destination document
is not filled.
2. Test the map. a. Right-click NWCustomerOrder_To_FKSupplierPO.btm, click Properties and
Testing a map provides a way to configure the following properties:
catch exceptions or logical errors Property Value
by using an actual instance
document without deploying an TestMap Input Instance C:\Labs\Work\Lab03\CustomerOrder.x
entire solution. ml
TestMap Input XML
b. Click OK to save the properties.
c. Right-click NWCustomerOrder_To_FKSupplierPO.btm and click Test Map.
A link to the XML instance is shown in the Output window.
d. Click the link while pressing CTRL to open the resulting XML file.

Page 6 of 7
Working with Maps

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


1. Build the project. a. On the File menu click Save All.
The assembly is compiled into a b. In the Solution Explorer, right-click NWMessaging and click Build.
DLL file and saved in the
…\bin\Development folder within
The results of the compiled project are displayed in the Output window.
the project folder. c. Close Visual Studio.

Page 7 of 7

Вам также может понравиться