Stephen W. Thomas BizTalk Blog

100% Pure BizTalk
posts - 133, comments - 195, trackbacks - 427

My Links

News

Subscribe to my blog via:


Add to Google

Visit my website at:
www.BizTalkGurus.com

Archives

BizTalk 2004 Samples

BizTalk 2006 Samples

BizTalk Videos

BizTalk White Papers

BizTalkBlogs.com

Great BizTalk Blogs

Other Links

Receiving SQL 2005 XML Data in BizTalk 2006

SQL Server 2005 offers many exciting new features.  One of them is the support for Xml as a data type.  On the surface, this looks great since BizTalk likes Xml.  But, we come to learn that the Xml Data Type is not supported using the SQL Adapter inside BizTalk.

 

But, with a little effort you are easily able to accept Xml Documents that are all in one cell from SQL Server into BizTalk using the Receive Adapter. 

 

Here is the scenario:  The client is using a SQL table as a type of queue.  Messages are writing as full Xml Documents into a single cell of the table, along with an id, datetime, and a status.   This data needs to be inserted into BizTalk.  In the past, I have used a windows service to send the messages to a MSMQ queue and then into BizTalk.  My new approach is to use a simple stored procedure that I call from a Receive Port to extract out the Xml and update the states on the table. 

 

In addition, you can use one Receive Location to receive many different message types.  Then you can use message box routing (Direct Binding) to route many different message types to Send Ports or Orchestrations.  You can also map on the Receive Port if needed. 

 

The downside is you can not auto generate the schema using the SQL Schema Generation Wizard.  You will need to generate them manually based on the Xml messages you will be putting into your queue table.

 

I have put together a sample complete with a sample database, stored procedure, and BizTalk code. 

 

Download: Working with SQL 2005 XML Data in BizTalk 2006 Sample

 

This includes an importable MSI and Binding files if you want to build the code yourself.  See the readme.txt file for more set up information.

 

Print | posted on Monday, July 17, 2006 9:10 PM |

Feedback

Gravatar

# re: Receiving SQL 2005 XML Data in BizTalk 2006

Very nice! We were looking at using MSMQ or SSSB to do the queuing, but this approach seems much more elegant and simple. Thanks!
7/18/2006 8:21 AM | Bryant Likes
Gravatar

# re: Receiving SQL 2005 XML Data in BizTalk 2006

If you go this route, let me know how it works for you.

I tested it quite a bit and everything seemed to work great. This approach would have saved me some time on several of my past projects.

Best of luck.

Stephen W. Thomas
7/18/2006 8:30 AM | Stephen W. Thomas
Gravatar

# re: Receiving SQL 2005 XML Data in BizTalk 2006

While I like a sql queue approach, you do need to be careful with the xml type. The xml type only stores the xml infoset. It's a graph of the infoset. It is not an exact copy of the xml data.

See http://msdn2.microsoft.com/en-us/library/ms187508.aspx

For most scenarios storing the infoset is probably all you need. However, review the above link to make sure the infoset will meet your requirements. In our case, we needed the exact xml stored for auditing purposes so we stored the message data in a nvarchar(max) field.
7/26/2006 4:23 AM | rclb
Gravatar

# re: Receiving SQL 2005 XML Data in BizTalk 2006

Thje example works flawlessly but I wonder about consuming data from an HTTP Endpoint exposed as a webservice from SQL 2005.

And another example showing inserting data into the SQL Table would be good.
8/28/2006 5:15 AM | George Bryan
Gravatar

# re: Receiving SQL 2005 XML Data in BizTalk 2006

Works great!
Remember to change the server name in the project file to be able to deploy. It is unfortunately set to laptop01..
4/25/2007 6:31 AM | Thomas Glod
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 

Powered by: