From Silverlight development to Biztalk development, things have changed pretty soon.
Scenario
We are integrating two applications, where a particular field of the source maps to another field in destination. But their values aren’t so agreeable, for example, say we have a field called OrderStatus in Application1 which maps to a field named OrderStatus in Application2, but the list of possible values are different.
| Field | Application1 | Application2 |
| OrderStatus | 1 | Delivered |
| OrderStatus | 2 | Pending |
Table 1
How do you go about mapping them? Apparently there are a number of ways to solve the problem as briefly explained by Michael Stephenson. The pattern that was suggested to me was to use Cross Referencing Functions. Michael Stephenson’s post explains the underlying concept well, but it falls short of providing a complete example. The MSDN page stops at how to import data for cross reference functoids. What I needed was a simple example as to how to use it. So I decided to do one myself.
Solution
Lets take the above problem and solve it.
First we need to have all the data needed (as per Table 1) in our database. For this purpose we will set up the following xml files.
listOfAppType.xml
Contains a types of the applications.
<?xml version="1.0" encoding="utf-8"?>
<listOfAppType>
<appType>
<name>Application1</name>
<description/>
</appType>
<appType>
<name>Application2</name>
<description/>
</appType>
</listOfAppType>
listOfAppInstance.xml
Contains the instance names of the applications<?xml version="1.0" encoding="UTF-8"?>
<listOfAppInstance>
<appInstance>
<instance>Application1Instance</instance>
<type>Application1</type>
<description/>
</appInstance>
<appInstance>
<instance>Application2Instance</instance>
<type>Application2</type>
<description/>
</appInstance>
</listOfAppInstance>
listOfIDXRef.xml
Contains the list of fields to be stored for mapping.<?xml version="1.0" encoding="UTF-8"?>
<listOfIDXRef>
<idXRef>
<name>OrderStatus</name>
<description>Status of the order</description>
</idXRef>
</listOfIDXRef>
listOfIDXRefData.xml
Contains the values of the fields in each application and the common values used to refer to them.<?xml version="1.0" encoding="UTF-8"?>
<listOfIDXRefData>
<idXRef name="OrderStatus">
<appInstance name="Application1Instance">
<appID commonID="D">1</appID>
<appID commonID="P">2</appID>
</appInstance>
<appInstance name="Application2Instance">
<appID commonID="D">Delivered</appID>
<appID commonID="P">Pending</appID>
</appInstance>
</idXRef>
</listOfIDXRefData>
SetupFiles.xml
A setup file containing the paths to all these xmls<?xml version="1.0" encoding="UTF-8"?>Now lets put them into the database. For this will will use the BTSXRefImport tool found in the biztalk directory. Use the following command to do this.
<Setup-Files>
<App_Type_file>G:\Microsoft\Biztalk\Biztalk Server Examples\CrossReferenceFunctoids\listOfAppType.xml</App_Type_file>
<App_Instance_file>G:\Microsoft\Biztalk\Biztalk Server Examples\CrossReferenceFunctoids\listOfAppInstance.xml</App_Instance_file>
<IDXRef_file>G:\Microsoft\Biztalk\Biztalk Server Examples\CrossReferenceFunctoids\listOfIDXRef.xml</IDXRef_file>
<IDXRef_Data_file>G:\Microsoft\Biztalk\Biztalk Server Examples\CrossReferenceFunctoids\listOfIDXRefData.xml</IDXRef_Data_file>
</Setup-Files>
Lets do the mapping part. Drag and drop the Get Common ID functoid and configure its input as follows:
The first Input being the name of the common field, the second the name of the application instance and the third being the value for the application
Then drag and drop the Get Application ID functoid and configure its input as follows:The first Input being the name of the common field, the second the name of the application instance and the third being the common id from the Get Common Id functoid.
Let test our Map. Given the following input:
<ns0:Root xmlns:ns0="http://CrossRefrence.Schema1">Our Map gives the following output:
<OrderStatus>1</OrderStatus>
</ns0:Root>
<ns0:Root xmlns:ns0="http://CrossRefrence.Schema2">
<OrderStatus>Delivered</OrderStatus>
</ns0:Root>
Home

![Command[1] Command[1]](http://i917.photobucket.com/albums/ad20/rameshsubramanian/Biztalk/Command.png)
![GetCommonIDIP[1] GetCommonIDIP[1]](http://i917.photobucket.com/albums/ad20/rameshsubramanian/Biztalk/GetCommonIDIP.png)
![GetApplicatIDIP[1] GetApplicatIDIP[1]](http://i917.photobucket.com/albums/ad20/rameshsubramanian/Biztalk/GetApplicatIDIP.png)
![Map[1] Map[1]](http://i917.photobucket.com/albums/ad20/rameshsubramanian/Biztalk/Map.png)
0 comments:
Post a Comment