Output custom formatted message from Orchestration

Published on : May 24, 2007

Category : BizTalk Server



Have you ever wanted to create a custom formatted message. For example if you define a message of type System.String inside your orchestration and output it via an adapter the result will be as shown below <?xml version=”1.0″ ?> <string>Hello there</string> this is because of the default serialization behavior of .NET base types within BizTalk. If in case you wanted to output the message as a simple string, in our case “Hello there” without any xml tags and processing instruction, you need to create your own .NET type with custom serialization and use it instead of System.String . In this post I’ll explain how you can achieve this seamlessly with a similar sample by creating your own class with your own custom formatting serialization technique to create a sample email text message from an XML message. The sample solution contains full working sample and the code is self explanatory.


We got a simple orchestration which takes an input XML message and produces the output in text format. biztalk orchestration receive/send ports   MSG_TEXT_EMAIL  is a message created from a custom .NET class called FormattedTextEmail. The message assignment shape got the following one line code, which assigns a .NET type to the Orchestration XLang message MSG_TEXT_EMAIL. MSG_TEXT_EMAIL = new FormattedEmail.FormattedTextEmail(MSG_XML_EMAIL.From, MSG_XML_EMAIL.To,MSG_XML_EMAIL.Subject, MSG_XML_EMAIL.Body); As you can see there is no MAP’s involved to do the transformation.


<ns0:EmailMessage xmlns:ns0=”http://www.digitaldeposit.net/sample/schema”> <From>sk@email.com</From> <To>gow@biz.com</To> <Subject>Hey are you alrigh</Subject> <Body>I found this sample really cool</Body> </ns0:EmailMessage>


From : sk@email.com To : gow@biz.com Subject : Hey are you alrigh Body : I found this sample really cool Download Sample: CustomEmailFormat

Executing the sample:

1. Extract the solution to C:BTSSamples 2. Open the visual studio solution, build and deploy it 3. Open BizTalk administration console, Open application “CustomEmailFormat”,  Bind orchestration and Start the application 4. Drop the sample message inside the folder “C:BTSSamplesCustomEmailFormatFileDropIn” 5. You should see the text output inside the folder “C:BTSSamplesCustomEmailFormatFileDropOut”

Related Reading:

http://msdn2.microsoft.com/en-us/library/bb418739.aspx Nandri! Saravana