Quantcast
Channel: BizTalk Experts » Labs
Viewing all articles
Browse latest Browse all 3

Using C# instead of using BizTalk Visual Mapper

$
0
0

The visual mapper of BizTalk that allows you to map an xml message to another xml message can be very handy when we’re talking about little xml files, but when you need to map a bigger xml file it gets very unstructured and difficult to maintain!

So check out this nice picture about the visual mapper that realizes a mapping between two ‘little’ xml files… Here you see only five lines:

Visual Mapper (SMALL)

Oke, but what if you have two xsd’s with 200 elements in it (at both sides). You’ll get something like this:

Visual Mapper (BIG)

As you can imagine, this mapping is very hard to maintain. You have to possibility to use tabs, but this is not going to make the mapping easier! So what can you do to simplify this?

1) Generate a code version of the XSD with a tool like XSD CodeGen
2) Create a new class with some public properties to Serialize and Deserialize the XmlDocuments.
3) Create a custom mapping to map one XmlDocument to the other. This will look like this:

oLine.Item.Item1 = Helpers.Left(oSource.Item1, 15);
oLine.Item.Item2 = Helpers.Left(oSource.Item2, 15);
oLine.Item.Item3 = Helpers.Left(oSource.Item3, 20);

So here you see every line under each other and I think this is a very easy way to maintain your mappings. You don’t have to deal with functoids because it’s a C# class and you can program whatever you like. When you put this mapping methods in a separate dll, you can easily deploy a mapping change with only a dll copy/gac method.

NOTE: Make sure that your mapping C# classes are Serializable. This is needed for the orchestrations and otherwise it won’t work!



Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images