Dynamic maps in BizTalk Orchestration

Requirement: I need to expose a BizTalk Rest service with multiple Verbs (Get/Post/Update) to front end system. When front end system calls BizTalk Rest service, for each Operation (Get/Post/Update) I need to construct request message to send to backend system and get the response back and need to construct response map and send the response back to Front End.

Solution1: For each operation I need to construct 2 maps (Request and Response) and 1 Orchestration, if I have 10 Get operations, I need to create 10 Orchestrations.

Solution2: Using BizTalk dynamic Maps concept, we can use single orchestration to call the maps dynamically from Orchestration.

We need to follow below steps in orchestration.

  • After receiving the message using Receive shape, we need to take an expression shape to extract the Operation name and assign to a string variable.

Expression Shape:

DynamicMaps1.jpg

Operation = RequestMessage(BTS.Operation);

//Operation is a string variable

//RequestMessage is the message type of receive shape.

//BTS.Operation is the context property and this value will be assigned in the Receive location for each operation.

// Pass the Operation name (which is extracted above) as input parameter to a C# component to get fully qualified request Map name.

requestMapName = varGetMapName.GetRequestMapName(Operation);

//requestMapName is a string variable

//varGetMapName is a variable of type C# Class where we have GetRequestMapName method.

  • Take Message Assignment Shape and write below code
DynamicMaps2.jpg

 mapType = System.Type.GetType(requestMapName);

transform(QueryRequest) = mapType(EnquiryRequest);

//mapType is a variable of type “System.Type”

// EnquiryRequest is a message which we receive in Receive Shape

// QueryRequest is a message which we construct (Backend system request message)

  • Take Send shape to send the above constructed message to Backend system through logical request and response port.
  • Take the Receive shape to get the backend system response.
  • Take Expression shape and write below code
DynamicMaps3.jpg

ResponseMapName = varGetMapName.GetResponseMapName(Operation);

//ResponseMapName is a string variable

//varGetMapName is a variable of type C# Class where we have GetResponseMapName method.

  • Take Message Assignment Shape and write below code.
DynamicMaps4.jpg

mapType = System.Type.GetType(responseMapName);

transform(EnquiryResponse) = mapType(QueryResponse);

//mapType is a variable of type “System.Type”

// EnquiryResponse is a message which we send to front end system.

// QueryResponse is a response message which we receive from Backend system

  • Send the above constructed response message to Front end system.

//C# method to get the Request Map name based on QueryType

public string GetRequestMapName(String QueryType)

        {

            string MapName = string.Empty;

            switch (QueryType)

            {

                case “Sample1”:

                    MapName = “BizTalk.Sample.InternalRequest, BizTalk.Sample.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4f9ac75c4a70e419”

                    break;

 case “Sample2”:

                    MapName = “Fully Qualified Map Name”

                    break;

 case “Sample3”:

                    MapName = “Fully Qualified Map Name”

                    break;

            }          

            return MapName;      

        }

//C# method to get the Response Map name based on QueryType

public string GetResponseMapName(String QueryType)

        {

            string MapName = string.Empty;

            switch (QueryType)

            {

                case “Sample1”:

                    MapName = “Fully Qualified Map Name”

                    break;

 case “Sample2”:

                    MapName = “Fully Qualified Map Name”

                    break;

 case “Sample3”:

                    MapName = “Fully Qualified Map Name”

                    break;

            }          

            return MapName;       

        }

BizTalk Server Monitoring

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: