Output custom formatted message from Orchestration

|  Posted: May 24, 2007  |  Categories: 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.

Orchestration:

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.

Input:

<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>

Output:

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

Author: Saravana Kumar

Saravana Kumar is the Founder and CTO of BizTalk360, an enterprise software that acts as an all-in-one solution for better administration, operation, support and monitoring of Microsoft BizTalk Server environments.

One Platform Operations, Monitoring and Analytics Software
BizTalk360

microsoft biztalk

Learn more

Over 500 customers across 30+ countries depend on BizTalk360

ServiceBus360

Azure Composite Application

Learn more

Start manage and monitor your Azure Services in minutes

One Platform - Operations, Monitoring and Analytics Software
BizTalk360

microsoft biztalk

Learn more

Over 500 customers across 30+ countries depend on BizTalk360

One Platform - Operations, Monitoring and Analytics Software
ServiceBus360

Azure Composite Application

Learn more

Start manage and monitor your Azure Services in minutes

Back to Top