LINQ in BizTalk - Follow up

Listen with webReader
Published 16 May 08 05:08 PM | Johan Hedberg

I've previously posted my ideas about using LINQ in BizTalk. At that point it was just theories, and following the links in the comments section of that post I wasn't the first to have them. Thanks to the red bits/green bits approach BizTalk Server can use LINQ today by using Visual Studio 2008 side-by-side with Visual Studio 2005. This post provides a working sample that does just that - uses LINQ in BizTalk by utilizing a helper assembly, built using Visual Studio 2008 and the .NET Framework 3.5, from a BizTalk Server 2006 R2 Orchestration (built using Visual Studio 2005). If you do have both Visual Studio 2005 and 2008 available, and this doesn't conflict with the rules of engagement you have as far as your environment goes, I think it's worth looking at.

The sample consist of the following parts:

  1. A library project named LINQHelperLibrary, with a method that takes in a XLangMessage, extracts the stream, wraps the stream in an XmlReader and feeds that into the constructor for an XElement. Using that XElement a LINQ to XML statement is performed to extract the totalt amount of a Purchase Order document. This library is built using Visual Studio 2008 and the .NET Framework 3.5 compiler.
  2. A BizTalk project named BizTalkLINQ, that contains a generated xsd schema and a very simple orchestration with an expression shape that calls the LINQHelperLibrary and passes in the message, receives the response and outputs a Trace.WriteLine. This project has a reference to LINQHelperLibrary as well as (an explicitly added) reference to System.Xml.Linq.

The sample requires the following:

  • BizTalk Server 2006 (I used R2)
  • Visual Studio 2005
  • .NET 2.0 and .NET 3.5
  • I am including the dll built using Visual Studio 2008, but if you wan't to build it yourself you'll need Visual Studio 2008.

To run the sample do the following:

  1. GAC LINQHelperLibrary.dll. (If you want to build it yourself do so using Visual Studio 2008 first)
  2. Build and Deploy BizTalkLINQ.
  3. Configure the orchestration by assigning it a host instance, a receive and a send port (use the XML pipeline).
  4. Feed a Purchase Order document into the Receive Port. A sample file is included in the sample (in the BizTalk LINQ\FileDrop folder)  - it originates from Sample XML File: Purchase Order in a namespace.
  5. Optionally display the value returned by the helper assembly by using DebugView while it runs. If you don't there really isn't muc to see...

Note: This isn't a LINQ to BizTalk implementation - implementing a provider for BizTalk is a totally different matter, this just uses LINQ to XML from within BizTalk.


Filed under: , , ,


No Comments

This Blog



    Twitter Updates

      Follow me on twitter


      Feedburner Subscribers

      Locations of visitors to this page


      All material is provided AS IS voiding any thinkable or unthinkable effect it might have for any use whatsoever. There... is that clear enough ;)