Tuesday, April 04, 2006

Handy Method for Serializing objects to Xml

In many of my recent projects, I have come across serialization of objects to xml.
I am sure thats a very common thing these days with so many stuff going on with respect to interoperability and platform independance air all around.

Everytime I came across this, I saw myself playing with the memory stream and xml serialization classes. To avoid all these nitty gritties, I have written just a very small function that will help us do just this.

I hope it will help somebody save time doing this thing -

public static XmlDocument SerializeObject(System.Type type, Object obj)
System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(type);
serializer.Serialize(stream, obj);
byte[] buffer = stream.GetBuffer();
string xmlDoc = System.Text.ASCIIEncoding.ASCII.GetString(buffer).Trim();
return xDoc;
catch (Exception ex)
return null;

This function does not have any requirements for namespace imports and can be used as a static method from your helper library.


Wednesday, February 22, 2006

Oracle Advanced Queues

Off topic a bit from the blog topic, but I thought it as worth mentioning.
I had a chance to take a look at the Oracle Advanced Queues while working on a piece of solution this time.
It seems to be a good messaging product based highly on the Oracle database. I found it quite similar to the MSMQT in the Microsoft domain.
Unfortunately though, the .net Oracle Data Provider does not offer much support for the AQ. However, you can take a glance at OO4O (Oracle Object for Ole) that fully supports this.

Now I am on a task of developing a custom Biztalk Adapter for the AQ. I hope to get it working with some custom C++ code developed by Casto Tiu.
You can find more information about this code here -

Lets hope now I am able to get this adapter in place asap.

Wajahat Abbas - The New MVP on the block

I consider this as a nice blog post to congratulate Wajahat Abbas on becoming a MVP for ASP.Net.
I have been working with him for past more than one year and admittedly that was a nice expirience.
He has just been conffered as the "Microsoft Most Valuable Professional" for ASP.net.

He works with e-Kalsoft - Pakistan as a .Net guy and has been actively involved in writing for the community. Along with it, he was also involved to a great extent in forming "INETA" - the organisation in Pakistan for .Net.

All the best Wajahat.
I am sure you will strive to keep the title the next year as well.


Tuesday, February 21, 2006

Back Again

Yeah I've been off-blogging for quite some time now.
Mostly due to a lot of work in the office... but also due to some personal things.

Infact, I was a bit more active offline writing quite a few articles for IT magazines in India.
I've been writing a series of Biztalk articles for PC Quest since Dec 05.
As I write this at the moment, I am also working on an article on SOA that will be published in a special PC Quest suppliment in March 06.

Well, about blogging, now I am back again and hope to get back to it with a bang.


Saturday, July 09, 2005

SRS - The latest crush

An year ago, I had a short stint with the reporting services. It wasnt much to explore in detail at that time, just to get it working for a project.
Working on one of the projects now, I had a chance to explore it again. Right from the first look, it has amused me as a reporting tool with fully loaded functionality.
In a nutshell, the SQL Reporting Services or SRS as it is more commonly known, allows you to connect to variety of data sources for fetching the data while producing commmon output formats like HTML, Excel, XML, CSV and lot others.
Coupled with it comes the security layer that deals with the authentication and authorization for the reports.This is where the users and their associated reports can be configured.
Developers can author the reports using the Report Definition Language (RDL) that is based on the XML format.The report manager interface allows direct uploading of RDL files to deploy the reports. Its that simple !
Report Management deals with the defining folders and resources, caching, data sources and several other things.The delivery mechanism for SRS allows delivery of reports using the on-demand (pull) model or the much loved event-based (pull) model, thereby offering flexibility of viewing the reports over the web or in email.

This post is concerned with a basic introduction to the SQL Reporting Service.More to follow with the problems that we overcame during the development phase !

Till then,
Happy Reporting !

Sunday, June 05, 2005

Biztalk 2006 Whitepapers

Salim Naim is a Senior Consultant working at Microsoft.
Fortunately, I had a chance of working quite closely with him on one of my projects.
He has recently published 3 whitepapers for Biztalk 2006 which are posted on Scott Woodgate's blog - http://blogs.msdn.com/scottwoo . (You would need to be a member of the biztalk group on msn to download these.)
The whitepapers give a nice idea about the new product and how it has been enhanced from its predecessors.
The Adapter Enhancement paper revolves around the changes made to various inbuilt Biztalk adapters. Its quite fascinating to know how easy the 2004 adapters have become for our use.
Apart from these, you also have a Setup and Migration paper that mentions how 2006 alleviates the pain when installing and configuring the product.

Happy Biztalking !!!

Thursday, May 26, 2005

Generating C# Source files for Biztalk Orchestrations

Another starlin undocumented stuff with BTS 2004....
Ever wondered, what does Biztalk do with all the orchestrations you do with it ?
Well, wait no longer ..
Cos, I've just discovered this amazing undocumented stuff that Charles Young has documented on his blog at - (http://geekswithblogs.net/cyoung/archive/2005/01/22/20633.aspx)

It says that you have a registry setting that generates C# files whenever you compile your Biztalk project.

Interesting isnt it ? Lets read further..
Microsoft controls the generation of C# files on compilation of Biztalk project by a registry key.
To enable the option, simply follow these steps -
1. Create a key called BizTalkProject at the following location -

2. Add to it a DWORD value called - GenerateCSFiles and set its value to 1 or anything more than that.

3. Restart Visual Studio, load the project and compile it.

You should get the c# files generated by Biztalk on compilation in your project folder.

Cool isnt it ?
Sometimes really keeps you wondering what all Easter Eggs you should be expecting with MS products !

Happy BizTalking !!!

Tuesday, May 24, 2005

Open HAT from Visual Studio

Hey Guys,
How many of us knew that HAT could be called from command prompt with the required query as a parameter.
I found this today while visiting the blog of Deepak Laxmanan (http://deepakl.blogspot.com/)

So now you can have a batch file for 100 most recent services as -
"C:\Program Files\Microsoft BizTalk Server 2004\BTSHatApp.exe" "C:\Program Files\Microsoft BizTalk Server 2004\Tracking\Queries\100MostRecentServices.trq"

This can be added to your Visual Studio Environment as External Command for direct access.

Whats more ? you can even edit the trq files with notepad or create new trq files to be in complete control of what the HAT opens !

isn't that cool ?

Happy Biztalking !!

Sunday, May 22, 2005

What I understand about the Biztalk Message Box

The message box is probably one of the basic concepts of BizTalk 2004 and also widely explained over the Internet. However, my purpose of writing this here is to jot down my understanding. Also if any BTS 2004 expert stumbles on it, he might take a chance to review and provide his comments which may further enhance my understanding.
So as it goes, the discussion here would start with the basics of a BizTalk message, further explaining the “Publish-Subscribe” architecture that is followed by the BizTalk Engine to explaining the actual role of message box in a simple orchestration.

So what are the Messages?
Messages are the basic elements of the BTS 2004. BizTalk being a "message-oriented" middleware, they form the core part of the workings.
Each piece of information that is processed by BizTalk is in form of "Messages", including the data that is passed over the WebService calls or the File receives.
Each message in BizTalk is treated as a multi part message with each part consisting of binary data that can represent an Xml document or a serialized .net class or just another message part.
Each message follows a defined Xml schema and has a document type that is same as the root element of the schema.
A message, by its nature, is immutable. This means that a message once created, cannot be modified at anytime during or after its processing. A message can be constructed either by the adapters or in the orchestration using the Construct Message shape. Construction of a message involves creating an entry in the message box database.
To modify a message, the message is copied over to another instance of the message and then modified. The original instance remains the same. This is useful for the message tracking feature offered by the BizTalk. The procedure helps the BizTalk Server to track the state of the messages at each step in the process.
Each message that is processed by BizTalk Server will posses a unique identifier (GUID) with which the message is distinguished in the message box.
In addition to this, a message can have its fields promoted as properties. Promotions help the filtering of the messages from the message box.
The promoted properties of the message are stored in a separate property schema that can be loaded in the memory as a property bag. This helps determining the properties of the message instance without loading the entire message in the memory. Hence property fields are used for filtering in the message subscriptions.

The Publish / Subscribe Architecture
Fundamental to BizTalk is the Publish / Subscribe Architecture. This architecture basically comprises of 2 main components. A publisher, who would be responsible to publish the message in the message store and a subscriber, who will subscribe to messages of a particular format so that he gets them whenever they are published.
Publishing refers to the process of inserting the messages in the message box database. Normally, a receive port, an orchestration or solicit send port would be involved in publishing any message to the message box.
A receive port would receive the message from the pipeline and publish it to the message box for an orchestration or a send port to pick up. An orchestration would publish the message usually while sending it using the send shape.
A solicit response port would actually publish the message when it receives a response from the end system.
The subscribers would indicate the message they would like to receive by a set of criteria or filters.
Thereby, whenever a message is posted or published to the message box database, a subscriber will be able to get the message based on the filters or criteria mentioned while subscribing. The filters can be specified only on the promoted fields on the message.

The Message Box
The message box is the heart of this messaging system. It manages the communication and routing of the messages to and from the BizTalk Server. The message box essentially comprises of one or more SQL Server databases and a Messaging Agent.
The SQL Server database(s), commonly known as the message box database is responsible mainly for persisting the messages, message parts and the promoted properties. Apart from this, the message box database also contains several stored procedures that determine the business logic for various tasks like Finding Subscribers, Message Routing etc.

The Messaging Agent provides a layer of abstraction over the message box database. It uses the .Net COM interop to expose a set of APIs that the BizTalk Core engine can use to communicate with the message box database.
In effect, the messaging agent abstracts and encapsulates the Message Box Database.
The Agent is used as an interface by the BizTalk Core engine as well as other publisher components including the Adapter framework.

The Big picture
Getting together the above mentioned pieces, let us try to get the whole picture with a sample orchestration.
Let’s consider a simple file transfer orchestration for the purpose.
The orchestration would simply receive a XML message from the file adapter, work over it, passing through a simple map and the modified message will be sent to another file system location using the File Adapter again.
A File drop in the file receive folder would invoke the receive location that will pickup the message handing it over to the File Adapter.
The Adapter takes up the responsibility from here to get the data in the Biztalk paradigm.
Once through the adapter, the message is handed over to the pipeline where it will be validated and any format conversions, if required will be carried out.
The pipeline ensures that the message is converted in a valid xml and then posts the message to the message box. Based on the message type and the promoted properties, the Message Agent will find the subscribers that will be interested in consuming the message. A routing failure occurs if there is no subscriber interested in the published message. This condition would normally occur if the receive location is enabled, but the orchestration is not enlisted / started.
The consumer here is the orchestration that is waiting for this message. Alternatively, a consumer can also be a send port to which the message can be directly routed to. (The mentioned scenario can also be executed with help of a receive and send port and a map without any orchestration).

The subscriber here will be the logical receive port that is configured in the orchestration.
As a consumer, the receive shape will consume the message and activate the orchestration. The message is carried over to the transform shape. The transform shape, as we know has to be in the Construct Message scope. The cause for this enforcing can be traced back to the same fact, that messages, by design, are immutable.
Therefore, when transforming, it is mandatory to create a new instance of the message. This is enforced by the Construct Message scope. The Transform shape will create new message using the maps defined.
This message will be carried over to the send port will eventually write the message to the file using the File Adapter.

Hence, as we look at it, the BizTalk Message Box database forms an integral part in any of the processes that can be carried out by the Microsoft BizTalk Server 2004. As seen, even in cases where we would not need an orchestration, the message box would be involved in transportation of the messages from the physical receive locations to the send ports.

Happy Biztalking!!

My .Net and Biztalk Space

Welcome to my .net and Biztalk space.
Here you will find write ups that I will be writing about my favourite technologies - Microsoft .net and Microsoft Biztalk Server.
I have also started the RSS feed for this blog. So whenever I post any blog here, you can get it immediately in your rss reader from -