Tuesday, April 15, 2008

Debatching XML using Index Functoid and Map parameters

Scenario:
In one of the applications that I am actively working on has need to de-batch a Product from an XML which has "n" number of products in it, and persist one product at a time by calling a stored procedure. I have to loop through the collection of products and persist individual Product. Just to make it worse, each of the stored procedure calls need more than the information provided in the Product node.

Solution:
There are many ways of retrieving the product information from the XML, like XPaths and loops. But, in this scenario I wanted to try something different. I decided to use a combination of - Index Functoids, Parameters to maps, and looping of Products. I did the following to accomplish this task -

a. I created a schema which holds the index of the loop, and called it context schema. A new message of this type will be created in every iteration of the loop.


b. I created a interesting multi-part message map. It has 2 input schemas - the order schema with multiple products in it; the second one is the above context schema. The interesting thing here is that, I can pass the index of the loop into the map and get the correct product out of the product collection, and pass the values to the target SQL request schema.


c. A simple Orchestration does the rest of the work. It looks like below -



If you look at it closely it just does the following to accomplish the task:

1. Get Item Record Count Expression shape - gets the count of Products in the order message.



2. while the there are products continue the loop.



3. Construct a context message that will hold the current index value of the loop. This message will be used as a "parameter to the map".



4. Create a map which

a. takes two input messages



b. and gives one message which will be used in calling the stored procedure



5. The stored procedure is now called with the request and a response comes back from it.

6. Finally, the loop is incremented to pick the next Product from the Order message.


That's it. Now you know how easy it is to use Index functoid and multi-part maps to get the specific information from a record.

3 comments:

Anonymous said...

Hi
I work with BizTalk server 2006 and I have a big problem with it, I will be thankful if you can help me.
I want to create a process in BizTalk orchestrator which runs in SharePoint and assign tasks to users.

I can create process and run it in SharePoint but all tasks (of process) is run for one user, So my problem is how to assign each task to each user (SharePoint users).
Best Regard

Kishore Dharanikota said...

Can you be more elaborate on the scenario that you are attempting to resolve? Thx.

Anonymous said...

Hi
sorry for my bad english writing!

I create an orchestartion process in biztalk and i assign it to "sharepoint" by ports, i send "data form" from orchestartion to sharepoint so user can modify and return forms. i can do these things but my problem is that i can not use different users in sharepoint !

Help!