Click here to Skip to main content
15,917,808 members
Articles / Programming Languages / C#
Article

Configuring BizTalk Orchestrations to handle un-typed messages

Rate me:
Please Sign up or sign in to vote.
4.29/5 (13 votes)
2 Mar 2006CPOL3 min read 68.8K   606   26   1
This article describes how to create/handle un-typed messages in BizTalk Server 2004 orchestrations.

Introduction

A typical orchestration in BizTalk deals with several kinds of messages. A message in BizTalk is always strongly typed. It is usually associated to some schema defined in the project. A Receive/Send shape in an orchestration is tied to a message declared in the Orchestration View. In the case of an un-typed message, the message type is set to 'System.Xml.XmlDocument', instead of a schema type. The class "XmlDocument" is a super class for all XML messages, and hence it can hold any type of XML message and subsequently any type of orchestration message. To summarize, an un-typed message is one whose message type is set to "XmlDocument" in an orchestration.

Example - processing un-typed messages

Consider that we are integrating several small messages into a StoreFront application. This application deals with several kinds of messages like "Car", "Music" and "Book". These messages need to be integrated into a "StoreFront" message. So, a designed orchestration would receive several different types of messages. The orchestration in the article is shown below:

Image 1

In the above orchestration, the "Send" and "Receive" shapes can handle any type of message. It is because the "Receive" shape is associated with a message which is of type "XmlDocument".

The Decision shape separates out the different kinds of messages.

C#
// Message Type consists of TargetNamespace#SchemaRootElementName
InputMessage(BTS.MessageType) == 
       "http://UntypedMessages.Book#BookMessage"

Image 2

C#
// Message Type consists of TargetNamespace#SchemaRootElementName
InputMessage(BTS.MessageType) == 
       "http://UntypedMessages.Car#CarMessage"

Image 3

C#
// Message Type consists of TargetNamespace#SchemaRootElementName
InputMessage(BTS.MessageType) == 
       "http://UntypedMessages.Music#MusicMessage"

Image 4

Notice the commonality in the above schemas. A quick explanation of one of the schemas is as follows:

The schema "Car.xsd" has the following properties:

  • RegID - The registration ID.
  • Make - The make of the car.
  • Model - The year of manufacture.
  • Operation - Can be either "BUY" or "SELL".
  • ExpectedPrice - The expected price.

The "InputMessage" message is specified in the Receive shape:

Image 5

The "OutputMessage" message is specified in the Send shape:

Image 6

The Message Assignment shape has the following lines of code:

C#
BookMsg = InputMessage;
regId = BookMsg.RegID;
category = "BOOK";
operation = BookMsg.Operation;
dataItem1 = BookMsg.Author;
dataItem2 = BookMsg.Pages;
expectedPrice = BookMsg.ExpectedPrice;

xmlDocument = new System.Xml.XmlDocument();  
xmlDocument.LoadXml("<ns0:StoreFront " + 
     "xmlns:ns0='http://UntypedMessages.StoreFront'><RegID>"+
 regId +"</RegID><Category>"+ 
 category +"</Category><ExpectedPrice>"+ 
 expectedPrice +"</ExpectedPrice><DataItem1>"+ 
 dataItem1 +"</DataItem1><DataItem2>"+ 
 dataItem2 +"</DataItem2><Operation>"+ 
 operation +"</Operation></ns0:StoreFront>");

OutputMessage = xmlDocument;

Line 1: The InputMessage is assigned to BookMsg, so as to retrieve its promoted properties.

Line 2-7: Retrieving the promoted properties of the BookMsg.

Line 8: Creating an instance of 'xmlDocument' and loading the XML for output.

Line 10: Assigning 'xmlDocument' variable to OutputMessage. This OutputMessage shall be sent through the "Send" port.

Image 7

Strong name and deployment!!

  1. Create a key file, using the "sn -k Untyped.snk", in the Visual Studio .NET command prompt.
  2. In the Solution Explorer, right-click on the "UntypedMessages" project properties and select "Assembly" and specify the key file name.
  3. In the Solution Explorer, right-click on the "UntypedMessages" project properties and select "Deploy".

Download and test the solution

  1. Download the zip file and extract the source code provided into any directory of your choice. Look into the folder "InputFiles" for sample input XML files. Place the input file in the receive location. Check the response in the "Out" folder based on the input message.
  2. In the BizTalk Explorer, right-click on the listed orchestration under the "Orchestration" folder and select "Bind...". Create a receive port and a receive location:

    Image 8

    In the BizTalk Explorer, right-click on the listed orchestration under the "Orchestration" folder and select "Start". The orchestration icon must turn to blue.

Quick takeaways

  1. Always set the Activate property to "true" for the first Receive shape in the orchestration.
  2. The "Terminate" shape is required in the orchestration, without which the project will not compile, since that particular branch does not generate any outgoing message.
  3. A BizTalk service needs to be re-started every time a deployment is done.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect AT&T Wi-Fi Services
United States United States
Naveen has done his Masters (M.S.) in Computer science, has started his career programming the mainframes and now has more than a decade of programming, development and design experience. Naveen has a sharp eye and keen observation skills. Naveen has worked for several companies and strived hard to build large scale business applications and bringing better solutions to the table.
Quite recently Naveen has built a fairly complex integration platform for a large bank. His hobbies include training, mentoring and research. Naveen spends his free time visiting National Parks nationwide.

Naveen has developed the BizTalk Control Center (BCC)
http://biztalkcontrolcenter.codeplex.com

Comments and Discussions

 
QuestionApplying map to outgoing message Pin
vitaly.pevgonen13-Jul-11 0:46
vitaly.pevgonen13-Jul-11 0:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.