<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gobbledygooks by Richard Hallgren &#187; R2</title>
	<atom:link href="http://www.richardhallgren.com/category/biztalk-2006/r2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.richardhallgren.com</link>
	<description>.NET, BizTalk and integration focused scribbles</description>
	<lastBuildDate>Fri, 23 Apr 2010 07:13:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Promote properties in a EDI schema using the EDI Disassembler</title>
		<link>http://www.richardhallgren.com/promote-properties-in-a-edi-schema-using-the-edi-disassembler/</link>
		<comments>http://www.richardhallgren.com/promote-properties-in-a-edi-schema-using-the-edi-disassembler/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 07:08:46 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[EDI]]></category>
		<category><![CDATA[R2]]></category>

		<guid isPermaLink="false">http://www.richardhallgren.com/promote-properties-in-a-edi-schema-using-the-edi-disassembler/</guid>
		<description><![CDATA[I’ve doing a lot of EDI related work in BizTalk lately and I have to say that I’ve really enjoyed it! EDI takes a while to get used to (see example below), but once one started to understand it I’ve found it to be a real nice, strict standard &#8211; with some cool features built [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve doing a lot of EDI related work in BizTalk lately and I have to say that I’ve really enjoyed it! EDI takes a while to get used to (see example below), but once one started to understand it I’ve found it to be a real nice, strict standard &#8211; with some cool features built into BizTalk!</p>
<pre>UNB+IATB:1+6XPPC+LHPPC+940101:0950+1'
UNH+1+PAORES:93:1:IA'
MSG+1:45'
IFT+3+XYZCOMPANY AVAILABILITY'
ERC+A7V:1:AMD'
IFT+3+NO MORE FLIGHTS'
ODI'
TVL+240493:1000::1220+FRA+JFK+DL+400+C'
...</pre>
</p>
<p>There are however some things that <em>doesn&#8217;t </em>work as expected …</p>
<h2>Promoting values</h2>
<p>According to the <a href="http://msdn.microsoft.com/en-us/library/bb226404(BTS.20).aspx" target="_blank">MSDN documentation</a> the EDI Disassembler by default promotes the following EDI fields: UNB2.1, UNB2.3, UNB3.1, UNB11; UNG1, UNG2.1, UNG3.1; UNH2.1, UNH2.2, UNH2.3.</p>
<p>There are however situation where one would like <em>other</em> values promoted. </p>
<p>I my case I wanted the C002/1001 value in the <a href="http://www.stylusstudio.com/edifact/d04b/BGM_.htm" target="_blank">BGM segment</a>. This is a value identifying the purpose of the document and I needed to route the incoming message based on the value. </p>
<p>The short version is that <em>creating a property schema, promoting the field in the schema and having the EDI Disassembler promoting the value <strong><u>will not work</u></strong> (as with the XML Disassembler)</em>. To do this you’ll need to use a custom pipeline component to promote the value. Rikard Alard seem to have come to the same conclusion <a href="http://rikardalard.wordpress.com/2009/06/15/promoted-properties-in-edi-schema-is-not-promoted-by-edireceive/" target="_blank">here</a>. </p>
<h2>Promote pipeline component to use</h2>
<p>If you don’t want to spend time on writing your own pipeline component to do this yourself you can find a nice “promote component” on CodePlex <a href="http://eebiztalkpipelinecom.codeplex.com/" target="_blank">here</a> by <a href="http://blog.eliasen.dk" target="_blank">Jan Eliasen</a>. </p>
<p>If you however expect to receive lots and lots of big messages you might want to look into changing the component to use XPathReader and custom stream implementations in the Microsoft.BizTalk.Streaming.dll. You can find more detailed information on how to do that in this <a href="http://msdn.microsoft.com/en-us/library/ee377071(BTS.10).aspx" target="_blank">MSDN article</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardhallgren.com/promote-properties-in-a-edi-schema-using-the-edi-disassembler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Streaming pipeline and using context ResourceTracker to avoid disposed streams</title>
		<link>http://www.richardhallgren.com/streaming-pipeline-and-using-resourcetracker-to-avoid-disposed-objects/</link>
		<comments>http://www.richardhallgren.com/streaming-pipeline-and-using-resourcetracker-to-avoid-disposed-objects/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 08:50:16 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[BizTalk]]></category>
		<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[BizTalk 2009]]></category>
		<category><![CDATA[Pipelines]]></category>
		<category><![CDATA[R2]]></category>

		<guid isPermaLink="false">http://www.richardhallgren.com/streaming-pipeline-and-using-resourcetracker-to-avoid-disposed-objects/</guid>
		<description><![CDATA[Recently there’s been a few really good resources on streaming pipeline handling published. You can find some of the here and here.
The Optimizing Pipeline Performance MSDN article has two great examples of how to use some of the Microsoft.BizTalk.Streaming.dl classes. The execute method of first example looks something like below.
public IBaseMessage Execute(IPipelineContext context, IBaseMessage message)
{
 [...]]]></description>
			<content:encoded><![CDATA[<p>Recently there’s been a few really good resources on streaming pipeline handling published. You can find some of the <a href="http://msdn.microsoft.com/en-us/library/ee377071(BTS.10).aspx" target="_blank">here</a> and <a href="http://msdn.microsoft.com/en-us/library/ff384124(BTS.10).aspx" target="_blank">here</a>.</p>
<p>The <a href="http://msdn.microsoft.com/en-us/library/ee377071(BTS.10,classic).aspx" target="_blank">Optimizing Pipeline Performance</a> MSDN article has two great examples of how to use some of the <a href="http://technet.microsoft.com/en-us/library/microsoft.biztalk.streaming(BTS.20).aspx" target="_blank">Microsoft.BizTalk.Streaming.dl</a> classes. The execute method of first example looks something like below.</p>
<pre class="brush: csharp;">public IBaseMessage Execute(IPipelineContext context, IBaseMessage message)
{
    try
    {
        ...
        IBaseMessageContext messageContext = message.Context;
        if (string.IsNullOrEmpty(xPath) &amp;&amp; string.IsNullOrEmpty(propertyValue))
        {
            throw new ArgumentException(...);
        }
        IBaseMessagePart bodyPart = message.BodyPart;
        Stream inboundStream = bodyPart.GetOriginalDataStream();
        VirtualStream virtualStream = new VirtualStream(bufferSize, thresholdSize);
        ReadOnlySeekableStream readOnlySeekableStream = new ReadOnlySeekableStream(inboundStream, virtualStream, bufferSize);
        XmlTextReader xmlTextReader = new XmlTextReader(readOnlySeekableStream);
        XPathCollection xPathCollection = new XPathCollection();
        XPathReader xPathReader = new XPathReader(xmlTextReader, xPathCollection);
        xPathCollection.Add(xPath);
        bool ok = false;
        while (xPathReader.ReadUntilMatch())
        {
            if (xPathReader.Match(0) &amp;&amp; !ok)
            {
                propertyValue = xPathReader.ReadString();
                messageContext.Promote(propertyName, propertyNamespace, propertyValue);
                ok = true;
            }
        }
        readOnlySeekableStream.Position = 0;
        bodyPart.Data = readOnlySeekableStream;
    }
    catch (Exception ex)
    {
        if (message != null)
        {
            message.SetErrorInfo(ex);
        }
        ...
        throw ex;
    }
    return message;
}</pre>
<p>We used this example as a base when developing something very similar in a recent project. At first every thing worked fine but after a while we stared getting an error saying:</p>
<blockquote>
<p>Cannot access a disposed object. Object name: DataReader</p>
</blockquote>
<p>It took us a while to figure out the real problem here, everything worked fine when sending in simple messages but as soon as we used to code in a pipeline were we also <a href="http://geekswithblogs.net/benny/archive/2007/02/15/106329.aspx" target="_blank">debatched</a> messages we got the “disposed object” problem.</p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2010/02/image1.png"><img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 10px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://www.richardhallgren.com/wp-content/uploads/2010/02/image_thumb1.png" width="449" height="546" /></a>It turns out that when we debatched messages the execute method of the custom pipeline ran multiple times, one time for each sub-messages. This forced the .NET Garbage Collector to run. </p>
<p>The GC found the XmlTextReader that we used to read the stream as unreferenced and decided to destoy it. </p>
<p>The problem is that <strong>will also dispose the readOnlySeekable-Stream stream that we connected to our message data object</strong>! </p>
<p><strong></strong></p>
<p><strong>It’s then the BizTalk End Point Manager (EPM) that throws the error as it hits a disposed stream object when trying to read the message body and save it to the BizTalkMsgBox!</strong></p>
<h2>ResourceTracker to the rescue!</h2>
<p>Turns out that the BizTalk message context object has a nice little class connected to it called the <em>ResourceTracker</em>. This object has a “AddResouce”-method that makes it possible to add an object and the context will the hold a reference to this object, <strong>this will tell the GC not to dispose it!</strong> </p>
<p>So when adding the below before ending the method everything works fine &#8211; even when debatching messages! </p>
<pre class="brush: csharp;">context.ResourceTracker.AddResource(xmlTextReader);</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.richardhallgren.com/streaming-pipeline-and-using-resourcetracker-to-avoid-disposed-objects/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tips and tricks on BizTalk generated SOAP Web Services</title>
		<link>http://www.richardhallgren.com/tips-and-tricks-on-biztalk-generated-soap-web-services/</link>
		<comments>http://www.richardhallgren.com/tips-and-tricks-on-biztalk-generated-soap-web-services/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 08:30:32 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[R2]]></category>

		<guid isPermaLink="false">http://www.richardhallgren.com/tips-and-tricks-on-biztalk-generated-soap-web-services/</guid>
		<description><![CDATA[Traditional SOAP Web Services might feel kind of old as more and more people move over to WCF. But a lot of integration projects still relay heavily on old fashion SOAP Web Services. 
Using BizTalk generated Web Services however has a few issues and one needs to add a few extra steps and procedures to [...]]]></description>
			<content:encoded><![CDATA[<p>Traditional SOAP Web Services might feel kind of old as more and more people move over to WCF. But a lot of integration projects still relay heavily on old fashion SOAP Web Services. </p>
<p>Using BizTalk generated Web Services however has a few issues and one needs to add a few extra steps and procedures to make them effective and easy to work with. This post aims to collect, link and discuss all those issues and solutions.</p>
<h2>1. Building and deploying</h2>
<p>BizTalk Server includes the “BizTalk Web Services Publishing Wizard” tool that integrates with Visual Studio. This is basically a tool to generate a <a href="http://en.wikipedia.org/wiki/Domain-specific_programming_language" target="_blank">DSL</a> based script for generating web services. </p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2009/06/image.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://www.richardhallgren.com/wp-content/uploads/2009/06/image-thumb.png" width="507" height="388" /></a> </p>
<p>The wizard collects information about what schema or a orchestration to expose, namespaces, names of service and method, where on IIS to publish the service etc, etc. </p>
<p>The output of the tool is then a xml file (a “WebServiceDescription” file) that has all the collected values in it.</p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2009/06/image1.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="image" border="0" alt="image" src="http://www.richardhallgren.com/wp-content/uploads/2009/06/image-thumb1.png" width="750" height="550" /></a> </p>
<p>As a final step Visual Studio uses the newly created description file as input to a class called WebServiceBuilder in the .NET Framework. It is this class that is responsible for interpreting the description, configure and generate the service.</p>
<p>A common procedure is to use the wizard and click thru it and input values for <strong><em>every</em></strong> single deployment. This is of course slow, error prone and stupid. </p>
<p>What is much better is to take a copy of the generated “WebServiceDescription” file, save it to your source control system and then programmatically pass the file to the WebServiceBuilder class as part of your deployment process. Possible changes to the details of the service can then be done directly in the description file. </p>
<p>I have seen this approach save lots of time and problems related to deployment.</p>
<ul>
<li>Paul Petrov has a great post on how to call the “WebServiceBuilder” class and pass the description file using C#.      <br /><a title="http://geekswithblogs.net/paulp/archive/2006/05/22/79282.aspx" href="http://geekswithblogs.net/paulp/archive/2006/05/22/79282.aspx">http://geekswithblogs.net/paulp/archive/2006/05/22/79282.aspx</a> </li>
<li>Michael Stephenson has a good post on how to used the “WebServiceBuilder” class via MSBuild.      <br /><a title="http://geekswithblogs.net/michaelstephenson/archive/2006/09/16/91369.aspx" href="http://geekswithblogs.net/michaelstephenson/archive/2006/09/16/91369.aspx">http://geekswithblogs.net/michaelstephenson/archive/2006/09/16/91369.aspx</a> </li>
</ul>
<h2>2. Fixing namespace</h2>
<p>Another annoying problem (I’d would actually go so far as calling it a bug) is the problem with the <em>bodyTypeAssemblyQualifiedName</em> value in the generated Web Service class.</p>
<p>This causes BizTalk to skip looking up the actual message type for the incoming message.&#160; As no message type exists for the message is in BizTalk mapping and routing on message types etc will fail.&#160; It is a know problem and there are solutions to it. I would also recommend take the extra time need to make this small “post process step” be part of your deployment process (see how <a href="http://www.richardhallgren.com/handle-the-bodytypeassemblyqualifiedname-soap-adapter-bug-in-msbuild-as-a-regex-ninja/" target="_blank">here</a>).</p>
<ul>
<li>Saravana Kumar discusses the problem and solutions in this great post.      <br /><a title="http://www.digitaldeposit.net/saravana/post/2007/08/17/SOAP-Adapter-and-BizTalk-Web-Publishing-Wizard-things-you-need-to-know.aspx" href="http://www.digitaldeposit.net/saravana/post/2007/08/17/SOAP-Adapter-and-BizTalk-Web-Publishing-Wizard-things-you-need-to-know.aspx">http://www.digitaldeposit.net/saravana/post/2007/08/17/SOAP-Adapter-and-BizTalk-Web-Publishing-Wizard-things-you-need-to-know.aspx</a> </li>
<li>Richard Seroter has a short and well written post published.      <br /><a title="http://blogs.msdn.com/richardbpi/archive/2006/09/15/Fixing-_2200_SOAP-_2F00_-Envelope-Schema_2200_-Error-In-BizTalk.aspx" href="http://blogs.msdn.com/richardbpi/archive/2006/09/15/Fixing-_2200_SOAP-_2F00_-Envelope-Schema_2200_-Error-In-BizTalk.aspx">http://blogs.msdn.com/richardbpi/archive/2006/09/15/Fixing-_2200_SOAP-_2F00_-Envelope-Schema_2200_-Error-In-BizTalk.aspx</a> </li>
<li>I have a post on how to solve the issue using MSBuild.      <br /><a title="http://www.richardhallgren.com/handle-the-bodytypeassemblyqualifiedname-soap-adapter-bug-in-msbuild-as-a-regex-ninja/" href="http://www.richardhallgren.com/handle-the-bodytypeassemblyqualifiedname-soap-adapter-bug-in-msbuild-as-a-regex-ninja/">http://www.richardhallgren.com/handle-the-bodytypeassemblyqualifiedname-soap-adapter-bug-in-msbuild-as-a-regex-ninja/</a> </li>
</ul>
<h2>3. Pre-compiling</h2>
<p>By default the “WebServiceBuilder” class generates a web service <em>without</em> pre-compiling it. Usually this is not a problem. <em>But</em> in some cases were one really on the web service being online and give a quick response-message the performance problems in this approach can be a huge problem.</p>
<p>When generating the web service without pre-compiling it IIS has to compile the service and then keep the compiled service in memory. That means that when IIS releases the service from memory there is a latency before IIS re-compiled the service, loaded it into memory and executed it. This is a known problem and I have seen this “slow first hit” issue been a frequent question the different forums.</p>
<p>The solution is to use the aspnet_compiler.exe tool and pre-compile the service and the use those pre-compiled dlls as the service. IIS then never has to recompile it and will serve initial hits much faster.</p>
<p>Here is an example of how we defined a target to do this as part of our deployment process&#160; using MSBuild.</p>
<ol>
<li>Pre-compile the service into a new folder </li>
<li>Clean out the “old” not compile service folder. </li>
<li>Copy the pre-complied service into the service folder </li>
</ol>
<pre class="xml:collapse:showcolumns" name="code">&lt;Target Name=&quot;CompileWeb&quot;&gt;
    &lt;Message Text=&quot;Uses aspnet compiler to compile the service into a new folder. Then copies the compiled content back into its original place&quot; /&gt;
    &lt;AspNetCompiler
        PhysicalPath=&quot;$(WebSiteServicePath)InitiateProjectService\&quot;
        VirtualPath=&quot;/WebServiceName&quot;
        TargetPath=&quot;$(WebSiteServicePath)$(WebServiceName)Compiled\&quot;
        Force=&quot;true&quot; /&gt;

    &lt;Folder.CleanFolder Path=&quot;$(WebSiteServicePath)$(WebServiceName)\&quot;/&gt;

    &lt;Folder.CopyFolder
                Source=&quot;$(WebSiteServicePath)$(WebServiceName)Compiled\&quot;
                Destination=&quot;$(WebSiteServicePath)$(WebServiceName)\&quot; /&gt;

&lt;/Target&gt;</pre>
<ul>
<li>Paul Petrov has two different articles here describing the process and also a different way that above on how to include the pre-compilation in you build process.<br />
    <br /><a title="http://geekswithblogs.net/paulp/archive/2006/03/30/73900.aspx" href="http://geekswithblogs.net/paulp/archive/2006/03/30/73900.aspx">http://geekswithblogs.net/paulp/archive/2006/03/30/73900.aspx</a>, <a title="http://geekswithblogs.net/paulp/archive/2006/04/19/75633.aspx" href="http://geekswithblogs.net/paulp/archive/2006/04/19/75633.aspx">http://geekswithblogs.net/paulp/archive/2006/04/19/75633.aspx</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.richardhallgren.com/tips-and-tricks-on-biztalk-generated-soap-web-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aggregated monitoring of BizTalk solutions using &quot;BizMon&quot;</title>
		<link>http://www.richardhallgren.com/aggregated-monitoring-of-biztalk-solutions-using-bizmon/</link>
		<comments>http://www.richardhallgren.com/aggregated-monitoring-of-biztalk-solutions-using-bizmon/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 15:25:20 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[BAM]]></category>
		<category><![CDATA[BizMon]]></category>
		<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[R2]]></category>

		<guid isPermaLink="false">http://www.richardhallgren.com/aggregated-monitoring-of-biztalk-solutions-using-bizmon/</guid>
		<description><![CDATA[Update 2009-08-11: This project turned out to be far more complicated and bigger than I first expected (ever heard that before?). Due to that and the fact that we wanted to have a company behind that could offer full-time support and stability “BizMon” has been released as a commercial product that you can find here.&#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><em><strong>Update 2009-08-11: </strong>This project turned out to be far more complicated and bigger than I first expected (ever heard that before?). Due to that and the fact that we wanted to have a company behind that could offer full-time support and stability “BizMon” has been released as a commercial product that you can find <a href="http://bizmontool.com/">here</a>.&#160;&#160; </em></p>
<p><em>I love to get some <a href="http://bizmontool.com/we-have-a-rtm-version">help from you</a><strong></strong> to test it and make it as good as possible. Even if it is commercial and cost money we have a free alternative for small environments and we work hard to keep the license price as low as possible.</em></p>
</blockquote>
<blockquote><p><em><strong>Update 2009-02-25:</strong> In the original post I said I&#8217;d post more on the architecture and the code during February 09. I&#8217;m however current struggling getting the needed legal rights etc, etc to be able to talk further about the &quot;BizMon&quot;-solution. It was harder than I thought &#8230; I&#8217;ll get back to posing on the subject as soon as I have that sorted.</em></p>
</blockquote>
<p>Integration of enterprise processes often ends up being very business critical. If a integration fails delivering the messages it was supposed to it usually means the business will be affected in a very negative way (for example losing money or delivering bad service). That of course means that monitoring the status of the integrations soon becomes very important (if you&#8217;re not into getting yelled at or potentially loosing your job).</p>
<p>Strangely enough <em><strong>BizTalk Server 2006 R2 <u>in my humble opinion</u> doesn&#8217;t come with the right tool to efficiently monitoring big enterprise integration solutions!</strong></em></p>
<h2>What do I mean by monitoring?</h2>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80image-20.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" align="right" src="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80image-thumb-9.png" width="240" height="180" /></a> Before I get myself deeper into trouble I&#8217;d like to define what I mean by monitoring. I think monitoring a BizTalk integration solution could be divided into four categories.</p>
<ol>
<li><strong>Infrastructure <strong>(traditional)</strong>        <br /></strong>This is the easy one and one that IT-pros and alike are used to monitor. Hardware status, network traffic, disk space, event logs etc all fall under this category. If the storing area for the databases start running low on memory we can be pretty sure it&#8217;ll eventually effect the integration somehow. </li>
<li><strong>BizTalk infrastructure        <br /></strong>This is where it starts getting a bit trickier. This category includes the status of receive locations, orchestrations, host instances and send ports. If a receive location is down no messages will be picked up (but we can also be sure of not getting any suspended messages). </li>
<li><strong>Suspended messages       <br /></strong>As most reader of this blog probably know suspended message is due to some sort of failure in BizTalk. It can be an actually exception in code or something that went wrong while trying to send messages. It&#8217;s however and important category to monitor. </li>
<li><strong>Heartbeat (monitoring actual successful traffic)       <br /></strong>While the points 1-3 above focuses on errors and that things being inactive this category actually monitors that the integration <em>runs as expected</em>.
<p>To me this final point is almost the most important one. What I mean is that if everything runs as expected and we&#8217;re sending the expected amount of messages in the right pace everything else must be ok &#8211; right? It&#8217;s however the one that in my experience almost always overlooked! </p>
</li>
</ol>
<h2>&quot;What do you mean &#8216;Not the right tools to monitor&#8217;? We have loads of tools in BizTalk 2006 R2!&quot;</h2>
<p>OK. So let&#8217;s see what tools we have available actually monitor the categories above.</p>
<ol>
<li><strong>Infrastructure <strong>(traditional)</strong></strong>      <br />I won&#8217;t discuss this kind of monitoring in this post. There are loads of tools (all from the <a href="http://www.microsoft.com/systemcenter/operationsmanager/en/us/default.aspx" target="_blank">huge expensive enterprise ones</a> to plenty of <a href="http://www.nagios.org/" target="_blank">good open-source alternatives</a>) for this and you&#8217;re probably already using one or several of them already. </li>
<li><strong>BizTalk infrastructure        <br /></strong>There are a couple of way of achieving this. One of the is to use the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=389FCB89-F4CF-46D7-BC6E-57830D234F91&amp;displaylang=en" target="_blank">Microsoft BizTalk Server Management Pack for Operation Manager</a>. It does however of course require that you have invested in System Center Operation Manager already &#8230;
<p>Another way is to either use the <a href="http://technet.microsoft.com/en-us/library/microsoft.biztalk.explorerom.aspx" target="_blank">ExplorerOM classes</a> or connecting directly to the BizTalk configuration database and code your own report of some sort.</p>
<p>The final (and most common way in my experience) is to try and document the correct configuration and settings and then have someone check these manually (if you&#8217;re that person I feel for you &#8230;).</p>
</li>
<li><strong>Suspended messages       <br /></strong>Suspended messages are of course very important to monitor and it&#8217;s for some reason also the first thing developers think of monitoring when developing BizTalk integration (maybe because of the fact that they&#8217;re similar to traditional exceptions in software). There are also here a couple of different ways to solve the problem.
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=389FCB89-F4CF-46D7-BC6E-57830D234F91&amp;displaylang=en" target="_blank">Microsoft BizTalk Server Management Pack for Operation Manager</a> mentioned above has the functionality to monitor and altering on suspended messages.</p>
<p>BizTalk Server fires <em><a href="http://msdn.microsoft.com/en-us/library/aa547324.aspx" target="_blank">the MSBTS_ServiceInstanceSuspendedEvent</a></em> WMI event every time a service instance gets suspended. It&#8217;s fully possible to write a service that watches for this event and then for example sends some sort of alert. Darren Jefford has an example on how do something like that in <a href="http://blogs.msdn.com/darrenj/archive/2004/03/30/104135.aspx" target="_blank">this post</a>. </p>
<p>In BizTalk 2006 <a href="http://msdn.microsoft.com/en-us/library/aa578516.aspx">Failed Message Routing</a> was introduced. This gives the developer the possibility to subscribe to suspended messages. These can then for example be sent out to file system or written to a database. <a href="http://msdn.microsoft.com/en-us/library/cc487894.aspx">Microsoft ESB Guidance for BizTalk Server 2006 R2</a> Exception management component uses this approach. The problem with this approach is however that the message is moved out of BizTalk and one loses all the built in possibilities of resending them etc.</p>
</li>
<li><strong>Heartbeat (monitoring actual successful traffic)
</p>
<p>       <a href="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80image-4.png"><img style="border-right-width: 0px; margin: 0px 0px 5px 10px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" align="right" src="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80image-thumb-1.png" width="400" height="363" /></a>As I said before I think this is a very important metric. If you can see that messages travel through BizTalk in a normal rate things much be pretty ok – right? Without doing to much coding and developing you own pipeline components for tracking etc there are two options.</strong>
<p>The first one is of course using the <a href="http://msdn.microsoft.com/en-us/library/ms943738.aspx" target="_blank">Health and Activity Tracking</a> tool (HAT). This shows a simple view of receives, processed and sent messages. I hate to say it but the HAT tool is <em><strong>bad</strong></em>. It&#8217;s slow, it&#8217;s hard to use, it&#8217;s hard to filter information, it times out, it doesn&#8217;t aggregate information, it&#8217;s basically almost useless &#8230; (Just to make one thing clear: I make my living working with BizTalk and <em>I really enjoy</em> the product but tracking and monitoring is really one of it&#8217;s ugly sides. I hate to say it.)</p>
<p>The other option is to develop a simple <a href="http://msdn.microsoft.com/en-us/library/aa972199.aspx" target="_blank">BAM tracking</a> profile to monitoring the send and receive port ports of the different processes.</p>
</li>
</ol>
<p>So to repeat what I said earlier: no I don&#8217;t think BizTalk comes with the right tool to monitor integration solutions. I do however think that the platform has the capabilities to create something that could close that gap in the product.</p>
<h2>What I need!</h2>
<p>Much of what’s discussed in this post can be solved using the <a href="http://msdn.microsoft.com/en-us/library/ms943596.aspx">BizTalk Administrations Console</a> (to manually monitor BizTalk infrastructure status) or in the <a href="http://technet.microsoft.com/en-us/library/ms943738.aspx">Health and Activity Tracking</a> tool (to manually monitor traffic). <em><strong>The aim of this post is however to discuss the possibilities to use this information, aggregate it and give the persons responsible for monitoring integration a dashboard that shows the current status of all integrations within the enterprise.</strong></em></p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80monitor-dashboard-2.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="Monitor DashBoard" src="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80monitor-dashboard-thumb.jpg" width="582" height="414" /></a></p>
<p>The dashboard monitor application need the following main features.</p>
<ul>
<li>In one single screen give an overview of the overall status of all the integrations. By status I mean if there are ports, orchestration or host instances that aren&#8217;t running that should be running or if there is any suspended traffic on that particular integration. </li>
<li>The possibility to show detailed information for a specific integration on what artifacts (ports, host instances etc) that are/aren&#8217;t running. How much traffic that&#8217;s been sent/received via the integration. When traffic was sent/received and if there&#8217;s any suspended messages on the integration. </li>
<li>The option to filter exclude specific artifacts from monitoring (for example receive locations that&#8217;s usually turned off etc). </li>
<li>Setting up monitoring by for example email and also define what integrations to be included in one specific monitoring (different persons are usually responsible for monitoring different integrations). </li>
</ul>
<h2>Introducing &quot;BizMon&quot;</h2>
<p>Based on the needs and &quot;requirements&quot; above I&#8217;ve started developing a application. The idea is to release it as open-source as soon as I get to a first stable version (I&#8217;d be very interested in help on practical details on how to do so). For now I&#8217;ll demonstrate it by showing some screenshots. The application is a web application based on <a href="http://www.asp.net/mvc/" target="_blank">ASP.NET MVC</a>.</p>
<h3>Screenshot: &quot;Applications&quot; page</h3>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80image-10.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80image-thumb-4.png" width="640" height="175" /></a></p>
<p>The above image shows a screenshot from the start page of the BizMon-application that shows the aggregated status of the entire BizTalk group it&#8217;s connected to. The applications is build to monitor one BizTalk group and the shown page displays all <a href="http://msdn.microsoft.com/en-us/library/aa560585.aspx" target="_blank">applications</a> within that <a href="http://msdn.microsoft.com/en-us/library/ms962428.aspx" target="_blank">BizTalk group</a>.</p>
<p>In the example image the two first rows have an OK status. That means that all of the monitored artifacts (receive locations, send ports, orchestrations and host instances) <em>within</em> that application are in a running and OK status.     <br />The yellow line on the <em>YIT.NO.Project</em>-application indicates a warning. That means that all the artifacts are in a OK status <em>but</em> there&#8217;re suspended messages within that application. The red line indicates that one or more of the monitored artifacts are in a inactive status.</p>
<p>Each row and application show when the last message on that application was received and/or sent. It also show how many suspended messages exists and when the last message got suspended.</p>
<h3>Screenshot: &quot;Application-detail&quot; page</h3>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80image-12.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80image-thumb-5.png" width="640" height="500" /></a></p>
<p>When clicking on a application on the main page previously shown the application-detail page is displayed for that application. This page shows detailed information on each of the artifacts within that application. I also shows suspended messages and the date and time of the last suspended.</p>
<p>It also displays a graph showing how many messages that has been processed by each of the ports. Currently the graph can view data from the last 7 days. In the screenshot above data from the 6th of January is shown and as it&#8217;s set to display data for a specific day the data is grouped in hours of that day. It&#8217;s also possible to view the aggregated data from all the traced days as show below. When viewing data from all days the graphs is grouped by days.</p>
<p>(The graph only shows data from the 6th of January as this is from test and there was no traffic of the previous days but I&#8217;m sure you get the idea &#8230;)</p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80image-14.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80image-thumb-6.png" width="640" height="192" /></a></p>
<h3>Screenshot: &quot;Application-detail&quot; page with inactive artifacts</h3>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80image-18.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://www.richardhallgren.com/wp-content/uploads/2009/01/windowslivewriteraggregatedmonitoringofbiztalksolutions-dd80image-thumb-8.png" width="640" height="395" /></a></p>
<p>This final page show details of an application with some inactive artifacts. The small cross highlighted by the arrow in the image show the possibility to filter out a single artifact from monitoring. If an excluded artifacts is failing the overall status of the application will still be OK and no alerts will be sent.</p>
<h2>Help!</h2>
<p>I&#8217;d love to <strong><em>get some input and feedback</em></strong> on all this. <em><strong>What do you think could be useful, what do you think won&#8217;t? Do you know of something similar, how do you solve this kind of monitoring?</strong></em></p>
<p>I&#8217;d also like to know any suitable placed to publish the code as an open-source project or is the best thing to just release it here on the blog? What do you think? Use the comments or <a href="mailto:richard.hallgren@gmail.com" target="_blank">send me a mail</a>.</p>
<h2>What&#8217;s next?</h2>
<p>I have a few thing on the alerts part of the application left and then I&#8217;ll release a first version. I&#8217;m hoping that could happened at the <strike>end of February 09</strike> (look at the update at the top of the post) . Make sure to <a href="mailto:richard.hallgren@gmail.com" target="_blank">let me know what you think</a>!</p>
<p>I&#8217;ll publish a follow-up post discussing the technical details and the architecture more in detail shortly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardhallgren.com/aggregated-monitoring-of-biztalk-solutions-using-bizmon/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Removing XML namespaces &#8211; revisit</title>
		<link>http://www.richardhallgren.com/removing-xml-namespaces-revisit/</link>
		<comments>http://www.richardhallgren.com/removing-xml-namespaces-revisit/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 07:25:33 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[R2]]></category>

		<guid isPermaLink="false">http://www.richardhallgren.com/removing-xml-namespaces-revisit/</guid>
		<description><![CDATA[I have a old post on removing XML namespace from outgoing messages using XSLT in a map on the send port. Removing XML namespace is usually a late requirement that shows up during integration tests with for example legacy systems that has problems reading XML and only finds XML namespaces messy and confusing and wants [...]]]></description>
			<content:encoded><![CDATA[<p>I have a <a href="http://www.richardhallgren.com/removing-namespace-from-outgoing-messages/" target="_blank">old post on removing XML namespace</a> from outgoing messages using XSLT in a map on the send port. Removing XML namespace is usually a late requirement that shows up during integration tests with for example legacy systems that has problems reading XML and only finds XML namespaces messy and confusing and wants it removed. </p>
<p>The post recently got commented by <a href="http://codebetter.com/blogs/jeff.lynch/" target="_blank">Jeff Lynch</a> (one of the <a href="http://codebetter.com/" target="_blank">codebetter.com</a> bloggers) asking me why I just didn&#8217;t create a schema without any XML namespace in it to represent the outgoing schema (see figure below) and then map to that in the send port.</p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2008/06/windowslivewriterremovingxmlnamespacesrevisit-834dremoving-xml-namespaces-revisit-2.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="242" alt="Removing XML namespaces - revisit" src="http://www.richardhallgren.com/wp-content/uploads/2008/06/windowslivewriterremovingxmlnamespacesrevisit-834dremoving-xml-namespaces-revisit-thumb.png" width="500" border="0" /></a> </p>
<p>Say for example that we have incoming messages like the one below with namespaces.</p>
<div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:baf9dd94-4deb-4a9a-a3b2-bf9d6a0ef7ab" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">ns0:BlahRoot </span><span style="color: #FF0000; ">xmlns:ns0</span><span style="color: #0000FF; ">=&quot;http://Sample.BlahIncomingSchema&quot;</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">
  </span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">BlahNode</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">Test Value</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">BlahNode</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">
</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">ns0:BlahRoot</span><span style="color: #0000FF; ">&gt;</span></div>
</pre>
</div>
<p>We&#8217;ve then defined a schema without namespace and map to that and get the following result.</p>
<div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:e9433bc0-3486-400f-9d61-3bfc529ef283" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">BlahRoot</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">
  </span><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">BlahNode</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">Test Value</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">BlahNode</span><span style="color: #0000FF; ">&gt;</span><span style="color: #000000; ">
</span><span style="color: #0000FF; ">&lt;/</span><span style="color: #800000; ">BlahRoot</span><span style="color: #0000FF; ">&gt;</span></div>
</pre>
</div>
<p>This method is of course much cleaner then any previous and it&#8217;s also more conceptually correct as the schema actually represents the contact between BizTalk and the receiving system (the contract is a message without namespace in it, <strong>not one with that we then remove</strong>).</p>
<p>The only problem with this kind of approach is that as BizTalk recognized the message type using a combination between root node and XML namespace we can&#8217;t have another schema with the <em>BlahRoot</em> root node without a defined XML namespace. Even if those two schemas would look totally different in structure and be two different message types BizTalk would be able to see the difference (to BizTalk they both be <em>#BlahRoot</em> message types).</p>
<p>Thanks Jeff for pointing this out to me. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardhallgren.com/removing-xml-namespaces-revisit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Does BizTalk have man-boobs?</title>
		<link>http://www.richardhallgren.com/does-biztalk-have-man-bobs/</link>
		<comments>http://www.richardhallgren.com/does-biztalk-have-man-bobs/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 07:14:04 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[R2]]></category>
		<category><![CDATA[Webcast]]></category>

		<guid isPermaLink="false">http://www.richardhallgren.com/does-biztalk-have-man-bobs/</guid>
		<description><![CDATA[I&#8217;ve just finished watching this webcast from QCon 2008 with Martin Fowler and Jim Webber. It&#8217;s basically their view on how integration middleware is used today and how we plan and implement our SOA and ESB project. 
Their main point is that we use much to bloated middleware (BizTalk is mentioned as an example here) [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just finished watching <a href="http://www.infoq.com/presentations/soa-without-esb" target="_blank">this webcast</a> from <a href="http://qcon.infoq.com/sanfrancisco-2008/conference/" target="_blank">QCon 2008</a> with <a href="http://martinfowler.com/" target="_blank">Martin Fowler</a> and <a href="http://jim.webber.name/" target="_blank">Jim Webber</a>. It&#8217;s basically their view on how integration middleware is used today and how we plan and implement our SOA and ESB project. </p>
<p>Their main point is that we use much to bloated middleware (BizTalk is mentioned as an example here) and that we should have a more agile approach to implement SOA and ESBs. They&#8217;ve used all the agile ideas (testing, isolated testable functionality, deliver small and often, continuous builds etc, etc) and applied them to integration &#8211; fair enough. I totally agree that trying to convert your complete enterprise architecture into a SOA architecture is a guaranteed failure. This is also <a href="http://www.microsoft.com/biztalk/solutions/soa/overview.mspx#EZB" target="_blank">something we heard for a while now from others</a> as well.</p>
<p>I do also agree that BizTalk is a huge platform and that it isn&#8217;t perfect in all aspects. IMHO it does however give us some important advantages compared to a custom coded message bus and services. I&#8217;ll try and list a few of them below.</p>
<ol>
<li><strong>Fixed architecture</strong>       <br />We don&#8217;t have invent the wheel every time. BizTalk is a product with an <a href="http://msdn.microsoft.com/en-us/library/aa561521.aspx" target="_blank">architecture</a> that one have to learn and use. There are times when this is a pain (did I hear low latency and BizTalk persistence points?) but it&#8217;s also a huge kick start to all projects once you learnt it. Once you figured out how you use the products you&#8217;ll actually have something up and running in no time.       </p>
<p>Isn&#8217;t an early delivery that we can test something good? I&#8217;m sure I can deliver a BizTalk based integration faster that some can using custom code when starting from scratch.       <br />&#160; </li>
<li><strong>Drag-and-drop</strong>       <br />There is a learning curve to BizTalk and all it&#8217;s tools but once one gotten over this one can move really fast, even without a deep understanding of .NET and software development (there are of course both pros and cons to this). I&#8217;ve seen projects with 50+ integration processes (to me that&#8217;s a big, complex project) where we actually used people fresh out of school, spent two weeks to teach them basic BizTalk and had them deliver critical parts of the projects. I&#8217;d like to see that happen custom coded ESB project with thousands lines of code &#8230;
<p>You probably get a nice design and implementation if you can hire 10 top developers and a couple of architects, but that isn&#8217;t always possible.       <br />&#160; </li>
<li><strong>Tools        <br /></strong>Does a custom code, lean approach, really scale in this scenario? Do you take the time to pause and build that management and configuration tool that you don&#8217;t get with a custom code project? I don&#8217;t say that we got the perfect view and control of our processes and messages in BizTalk but at least we got <strong>some</strong> control. At least I got the <a href="http://technet.microsoft.com/en-us/library/aa578089.aspx" target="_blank">BizTalk Administration Console</a> to let me see how my different application are doing, what messages and process etc that got suspended. At least I got the BAM framework where I can configure a tracking and monitoring in no time (usually &#8230;) etc, etc.&#160; <br />&#160; </li>
<li><strong>It works        <br /></strong>Say your implementing a process that receives purchase orders and that these orders might contain orders for a couple of millions dollars. Do you want to be developer that tells you boss that you think you might have lost a message due to a exception in your custom code? Of course you have 90% test coverage and continuous integration but you never tested for this exception case &#8230; I don&#8217;t want to be that developer/architect. </li>
</ol>
<p>I don&#8217;t say don&#8217;t test. I&#8217;m very pro testing and I really feel that agile is the right approach. I&#8217;m just saying I need something tested and safe to build this super critical solutions on. Something that I know works and that I can be really productive on and start solving business cases from minute one.</p>
<p>What do you think? Does BizTalk have man-bobs and is that only a bad thing? And does Martin Fowler really have leather pants on?    </p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardhallgren.com/does-biztalk-have-man-bobs/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Speaking at KNUG &#8211; Karlstad .NET User Group</title>
		<link>http://www.richardhallgren.com/speaking-at-knug-karlstad-net-user-group/</link>
		<comments>http://www.richardhallgren.com/speaking-at-knug-karlstad-net-user-group/#comments</comments>
		<pubDate>Fri, 09 May 2008 14:05:53 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[Presentation]]></category>
		<category><![CDATA[R2]]></category>

		<guid isPermaLink="false">http://www.richardhallgren.com/speaking-at-knug-karlstad-net-user-group/</guid>
		<description><![CDATA[Yesterday I presented the MasterData Management using BizTalk 2006 R2 talk (I&#8217;ll soon have a post out with the presentation in English) I recently held at Developer Summit at the local .NET user group in Karlstad (KNUG). 
KNUG is a new .NET user group that I actually helped start a couple of months ago. This [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I presented the <a href="http://www.richardhallgren.com/talking-at-developer-summit-on-masterdata-management-using-biztalk-2006/" target="_blank">MasterData Management using BizTalk 2006 R2 talk</a> (I&#8217;ll soon have a post out with the presentation in English) I recently held at Developer Summit at the local .NET user group in Karlstad (<a href="http://www.compare.se/index.asp?id=6221">KNUG</a>). </p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2008/05/windowslivewriterspeakingatknugkarlstad.netusergroup-e257janolof-on-how-to-be-cool.jpg"><img style="border-right: 0px; border-top: 0px; margin: 0px 15px 15px; border-left: 0px; border-bottom: 0px" height="243" alt="Janolof on how to be cool" src="http://www.richardhallgren.com/wp-content/uploads/2008/05/windowslivewriterspeakingatknugkarlstad.netusergroup-e257janolof-on-how-to-be-cool-thumb.jpg" width="237" align="right" border="0" /></a>KNUG is a new .NET user group that I actually helped start a couple of months ago. This meeting was the second meeting for the group. The meeting was attended by about 20 persons and we had two presentations on the agenda. Besides my own Thomas Heder showed the group some <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query" target="_blank">LINQ</a> and how he and his colleagues uses <a href="http://www.linqpad.net/" target="_blank">LINQPad</a> to develop and test there queries.</p>
<p>We also discussed future subjects, possible speakers and moving information on the group over to a <a href="http://communityserver.com/" target="_blank">Community Server</a> driven site. </p>
<p>Does anyone have any experience on Community Server and how the feature set matches those need for running a user group (managing users, blogs, email lists, calendar etc)? </p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardhallgren.com/speaking-at-knug-karlstad-net-user-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speaking at Developer Summit on Masterdata Management using BizTalk 2006</title>
		<link>http://www.richardhallgren.com/talking-at-developer-summit-on-masterdata-management-using-biztalk-2006/</link>
		<comments>http://www.richardhallgren.com/talking-at-developer-summit-on-masterdata-management-using-biztalk-2006/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 20:33:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[Presentation]]></category>
		<category><![CDATA[R2]]></category>

		<guid isPermaLink="false">http://www.richardhallgren.com/talking-at-developer-summit-on-masterdata-management-using-biztalk-2006/</guid>
		<description><![CDATA[I recently spoke at the leading developer conference here in Sweden called Developer Summit. The talk was called Masterdata Management using BizTalk 2006. The slides can be found here.
I can really recommend Developer Summit as a conference. Everything is super well organized and having the opportunity to listen to celebrities like David Chappell, Jim Webber, [...]]]></description>
			<content:encoded><![CDATA[<p>I recently spoke at the leading developer conference here in Sweden called <a href="http://www.expertzone.se/dev08/" target="_blank">Developer Summit</a>. The talk was called <em>Masterdata Management using BizTalk 2006</em>. The slides can be found <a href="http://www.richardhallgren.com/blogfiles/MasterData%20Management%20-%20Developer%20Summit%203.0.ppt" target="_blank">here</a>.</p>
<p>I can really recommend Developer Summit as a conference. Everything is super well organized and having the opportunity to listen to celebrities like <a href="http://www.davidchappell.com/blog/" target="_blank">David Chappell</a>, <a href="http://jim.webber.name/" target="_blank">Jim Webber</a>, <a href="http://dannorth.net/" target="_blank">Dan North</a> and <a href="http://blogs.thinktecture.com/cweyer/" target="_blank">Christian Weyer</a>&#160;<strong>in Sweden</strong> is really great! </p>
<p>This year I also liked the mix of presentation as some where more general presentation as for example&#160; Benjamin Ling who&#8217;s the director of platform at Facebook and who gave an insight to how the platform is managed and developed. I also really enjoyed (besides the obvious ones as for example Christian Weyer&#8217;s WCF talk) Frans H&#228;nel&#8217;s talk on the history and architecture behind a major price comparison site called <a href="http://prisjakt.nu/" target="_blank">prisjakt.nu</a> &#8211; very interesting and a great technical mix in otherwise Microsoft focused conference.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardhallgren.com/talking-at-developer-summit-on-masterdata-management-using-biztalk-2006/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Writing BizTalk context properties to a message from a WCF service using behaviors</title>
		<link>http://www.richardhallgren.com/writing-biztalk-context-properties-to-a-message-from-a-wcf-service-using-behaviors/</link>
		<comments>http://www.richardhallgren.com/writing-biztalk-context-properties-to-a-message-from-a-wcf-service-using-behaviors/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 17:43:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[R2]]></category>
		<category><![CDATA[Sample code]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://www.richardhallgren.com/writing-biztalk-context-properties-to-a-message-from-a-wcf-service-using-behaviors/</guid>
		<description><![CDATA[The new WCF adapter in BizTalk 2006 R2 offers a lot of new possibilities. One of those is to write data to the BizTalk Message context properties directly from an exposed WCF Service. A practical use of this technic could be to write the username from the Windows credentials of the calling client into the [...]]]></description>
			<content:encoded><![CDATA[<p>The new WCF adapter in BizTalk 2006 R2 offers a lot of new possibilities. One of those is to write data to the BizTalk Message context properties directly from an exposed WCF Service. A practical use of this technic could be to write the username from the Windows credentials of the calling client into the context of the BizTalk message. This could be useful as this information is encrypted in messages that are received via the WCF adapter and isn&#8217;t possible to read when inside BizTalk. I&#8217;ll try and demonstrate the technique in this post.</p>
<p>If you have used the SOAP adapter before you might know that all you had to do was to turn on Windows based security for the exposed SOAP service and the username was automatically promoted to the context of the incoming BizTalk message. That username could then be used for routing, tracking which user called the service or using the value in plain text when communicating further to other connected systems. However using the WCF adapter this is not true anymore &#8211; when using the new <a href="http://msdn2.microsoft.com/en-us/library/ms789036.aspx" target="_blank">WCF Message Security model</a> the username and password is encrypted in the message and once the message is received by BizTalk it&#8217;s to late to read it. Basically we have to read the username in the actual service and write it into our own context property (that doesn&#8217;t get encrypted).</p>
<p>One way of achieving this is to read the username in the service and then to add it to the WCF Message Headers. All WCF message headers will by default be written to a the BizTalk Message context property called <a href="http://msdn2.microsoft.com/en-us/library/bb259987.aspx" target="_blank">InboundHeaders</a> (in the <em>http://schemas.microsoft.com/BizTalk/2006/1/Adapters/WCF-properties</em> namespace). First we&#8217;ll create an EndpointBehavior that will use a MessageInspector to add the username to the message header.&#160; Finally we create BehaviorExtensionElement so we can use a WCF Custom Binding in BizTalk and configure it to add our new behavior.</p>
<h1>Creating the new EndpointBehavior</h1>
<p>To create the configurable behavior we&#8217;ll need the three classes we mentioned above.</p>
<ol>
<li>A class that implements the <a href="http://msdn2.microsoft.com/en-us/library/system.servicemodel.dispatcher.idispatchmessageinspector.aspx" target="_blank">IDispatchMessageInspector</a> interface to handle to reading and writing to the actual message. </li>
<li>A class that implements the <a href="http://msdn2.microsoft.com/en-us/library/system.servicemodel.description.iendpointbehavior.aspx" target="_blank">IEndpointBehavior</a> interface to define what kind of endpoint we&#8217;re creating and what it should do. </li>
<li>A class that implements the <a href="http://msdn2.microsoft.com/en-us/library/system.servicemodel.configuration.behaviorextensionelement.aspx" target="_blank">BehaviorExtensionElement</a> abstract class to&#160; create the behavior and make it configurable. </li>
</ol>
<div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:30a38abf-8115-47a6-9437-40a4eed2f89b" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;;overflow: auto;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">using</span><span style="color: #000000; "> System;
</span><span style="color: #0000FF; ">using</span><span style="color: #000000; "> System.Collections.Generic;
</span><span style="color: #0000FF; ">using</span><span style="color: #000000; "> System.Text;
</span><span style="color: #0000FF; ">using</span><span style="color: #000000; "> System.ServiceModel;
</span><span style="color: #0000FF; ">using</span><span style="color: #000000; "> System.ServiceModel.Channels;
</span><span style="color: #0000FF; ">using</span><span style="color: #000000; "> System.ServiceModel.Dispatcher;
</span><span style="color: #0000FF; ">using</span><span style="color: #000000; "> System.ServiceModel.Description;
</span><span style="color: #0000FF; ">using</span><span style="color: #000000; "> System.ServiceModel.Configuration;

</span><span style="color: #0000FF; ">namespace</span><span style="color: #000000; "> CustomWCFProperties.Behavior
{
    </span><span style="color: #808080; ">///</span><span style="color: #008000; "> </span><span style="color: #808080; ">&lt;summary&gt;</span><span style="color: #008000; ">
    </span><span style="color: #808080; ">///</span><span style="color: #008000; "> PromoteUserNameMessageInspector implements IDispatchMessageInspector and adds the name from the WindowsIdentity to a WCF header called WindowsUserName in the </span><span style="color: #008000; text-decoration: underline; ">http://CustomWCFProperties.Schema</span><span style="color: #008000; "> namespace. BeforeSendReply only returns as we're not interested in handling the response.
    </span><span style="color: #808080; ">///</span><span style="color: #008000; "> </span><span style="color: #808080; ">&lt;/summary&gt;</span><span style="color: #808080; ">
</span><span style="color: #000000; ">    </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> PromoteUserNameMessageInspector : IDispatchMessageInspector
    {
        </span><span style="color: #0000FF; ">#region</span><span style="color: #000000; "> IDispatchMessageInspector Members</span><span style="color: #000000; ">

        </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">object</span><span style="color: #000000; "> AfterReceiveRequest(</span><span style="color: #0000FF; ">ref</span><span style="color: #000000; "> System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
        {
            </span><span style="color: #0000FF; ">string</span><span style="color: #000000; "> windowsUserName </span><span style="color: #000000; ">=</span><span style="color: #000000; "> ServiceSecurityContext.Current.WindowsIdentity.Name;
            request.Headers.Add(MessageHeader.CreateHeader(</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">WindowsUserName</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">, </span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">http://CustomWCFProperties.Schema</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">, windowsUserName));
            </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">null</span><span style="color: #000000; ">;
        }

        </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> BeforeSendReply(</span><span style="color: #0000FF; ">ref</span><span style="color: #000000; "> Message reply, </span><span style="color: #0000FF; ">object</span><span style="color: #000000; "> correlationState)
        {
            </span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">;
        }

        </span><span style="color: #0000FF; ">#endregion</span><span style="color: #000000; ">
    }

    </span><span style="color: #808080; ">///</span><span style="color: #008000; "> </span><span style="color: #808080; ">&lt;summary&gt;</span><span style="color: #008000; ">
    </span><span style="color: #808080; ">///</span><span style="color: #008000; "> PromoteUserNameBehavior implements IEndpointBehavior and adds a message inspector to the dispatch behavior. Doesn't use any binding parameters, doesn't validate any configuration etc and can't be used in a client (only in a service).
    </span><span style="color: #808080; ">///</span><span style="color: #008000; "> </span><span style="color: #808080; ">&lt;/summary&gt;</span><span style="color: #808080; ">
</span><span style="color: #000000; ">    </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> PromoteUserNameBehavior : IEndpointBehavior
    {
        </span><span style="color: #0000FF; ">#region</span><span style="color: #000000; "> IEndpointBehavior Members</span><span style="color: #000000; ">

        </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
        {
            </span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">;
        }

        </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> ApplyClientBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)
        {
            </span><span style="color: #0000FF; ">throw</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> Exception(</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">The method or operation is not implemented.</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">);
        }

        </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher)
        {
            endpointDispatcher.DispatchRuntime.MessageInspectors.Add(</span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> PromoteUserNameMessageInspector());
        }

        </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">void</span><span style="color: #000000; "> Validate(ServiceEndpoint endpoint)
        {
            </span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">;
        }

        </span><span style="color: #0000FF; ">#endregion</span><span style="color: #000000; ">
    }

    </span><span style="color: #808080; ">///</span><span style="color: #008000; "> </span><span style="color: #808080; ">&lt;summary&gt;</span><span style="color: #008000; ">
    </span><span style="color: #808080; ">///</span><span style="color: #008000; "> Defines the behavior.
    </span><span style="color: #808080; ">///</span><span style="color: #008000; "> </span><span style="color: #808080; ">&lt;/summary&gt;</span><span style="color: #808080; ">
</span><span style="color: #000000; ">    </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">class</span><span style="color: #000000; "> PromoteUserNameBehaviorElement : BehaviorExtensionElement
    {
        </span><span style="color: #0000FF; ">protected</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">override</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">object</span><span style="color: #000000; "> CreateBehavior()
        {
            </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> PromoteUserNameBehavior();
        }

        </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">override</span><span style="color: #000000; "> Type BehaviorType
        {
            </span><span style="color: #0000FF; ">get</span><span style="color: #000000; "> { </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">typeof</span><span style="color: #000000; ">(PromoteUserNameBehavior); }
        }
    }
}</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>Finally we have to sign the assembly using a strong key and add it to the GAC.</p>
<h1>Configure the machine.config</h1>
<p>As we need BizTalk and the WCF adapter to pick up the need behavior and make it possible to configure our receive port we need to to add the behavior element to the <a href="http://msdn2.microsoft.com/en-us/library/ms229697(VS.71).aspx" target="_blank">machine.config</a>. The easiest way of doing this is to use the new <a href="http://msdn2.microsoft.com/en-us/library/ms732009.aspx" target="_blank">WCF Service Configuration Editor tool</a> and point to the machine.config file.</p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4promoteusernamebehavior-gac-2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="343" alt="PromoteUserNameBehavior GAC" src="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4promoteusernamebehavior-gac-thumb.jpg" width="500" border="0" /></a></p>
<p>After the dll been added and the machine.config file has been saved the the line below should have been added to the <a href="http://msdn2.microsoft.com/en-us/library/aa734726.aspx" target="_blank">&lt;behaviorExtensions&gt; element</a> (that is if you use the same strong name key as in the sample project I&#8217;ve linked here).</p>
<div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:6bc92cdd-9ed1-4dfc-954f-4e60721cfaae" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;;overflow: auto;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #0000FF; ">&lt;</span><span style="color: #800000; ">add </span><span style="color: #FF0000; ">name</span><span style="color: #0000FF; ">=&quot;addCustomWCFProperties&quot;</span><span style="color: #FF0000; "> type</span><span style="color: #0000FF; ">=&quot;CustomWCFProperties.Behavior.PromoteUserNameBehaviorElement, AddCustomWCFPropertiesBehavior, Version=1.0.0.0, Culture=neutral, PublicKeyToken=705e34637fdffc54&quot;</span><span style="color: #FF0000; "> </span><span style="color: #0000FF; ">/&gt;</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<h1>Create the BizTalk Receive Port and Receive Location</h1>
<p>Next thing to do is to start the BizTalk WCF Service Publishing Wizard. Choose to publish a service endpoint and make sure you enable metadata and create a receive location. In this example we&#8217;ll next choose to &quot;Publish schemas as WCF service&quot; and then define our service by naming service operations and so on.</p>
<p>When you then browse to the URL you choose to publish your service to you&#8217;ll see the nice example of how to instance the service you just defined. </p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4wsdl-code-example-2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="210" alt="WSDL code example" src="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4wsdl-code-example-thumb.jpg" width="500" border="0" /></a> </p>
<p>If we then send a request message to service (you&#8217;ll find a client as part of the <a href="http://www.richardhallgren.com/blogfiles/CustomWCFProperties.zip" target="_blank">attached solution here</a>) and inspect the message and its context properties in BizTalk we&#8217;ll see that the username of the calling client is nowhere to be found.</p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4message-no-username-2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="480" alt="Message No Username" src="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4message-no-username-thumb.jpg" width="499" border="0" /></a> </p>
<h1>Configure a WCF-Custom binding and adding a Endpoint Behavior</h1>
<p>To add the username to the message context we&#8217;ll need to add our newly created behavior to our service. We&#8217;ll do this by switch the service over to use a WCF-Custom binding to enable configuration. We then need to add the URL in the address field, define the binding type to a wsHttpBinding and to add our addCustomeWCFProperties behavior to the list of endpoint behaviors.</p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4add-endpoint-behavior-2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="480" alt="Add Endpoint behavior" src="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4add-endpoint-behavior-thumb.jpg" width="483" border="0" /></a></p>
<blockquote>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4note-2.gif"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 10px 10px 0px; border-right-width: 0px" height="14" alt="note" src="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4note-thumb.gif" width="14" align="left" border="0" /></a>&#160; NOTE: there is a limitation in the BizTalk WCF implementation in that you can&#8217;t create the WCF-Custom receive location that uses a HTTP in-process based binding (like the wsHttpBinding used in a WCF-Custom endpoint is) first and then use the WCF Publishing Wizard to only publish a metadata endpoint.</p>
<p><a href="http://www.topxml.com/code/cod-72_10213_biztalk-and-wcf-part-v-publishing-operations-patterns.aspx" target="_blank">Richard Seroter writes about it here</a> and I found the same thing to be true. </p>
<p><em>&quot;This error doesn&#8217;t have to do with mixing MEX endpoints and &#8220;regular&#8221; endpoints in the same IIS web site, but rather, creating MEX endpoints for in-process HTTP bindings seems to trigger this. <b>Note that an IIS-hosted MEX endpoint CAN be created for IIS-hosted HTTP endpoints, but not for in-process hosted HTTP endpoints.&quot;</b></em></p>
<p>If you however choose a different binding that Http or (as in this case) publishes the metadata first and then switches over to a custom binding you&#8217;re ok. </p>
</blockquote>
<p>If we then post another message to the service and inspect the message we&#8217;ll see that the behavior actually added a header and that it&#8217;s part of our BizTalk context properties. The adapter is also smart enough to know that this header isn&#8217;t part of the original headers and therefore stores in it&#8217;s own field within the context properties (you&#8217;ll find as part of the InboundHeaders block as well).</p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4message-username-4.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="221" alt="Message Username" src="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4message-username-thumb-1.jpg" width="500" border="0" /></a></p>
<p>One problem remains &#8211; the actual value of the user is nested inside a XML node and the property isn&#8217;t promoted.&#160; </p>
<h1>Extract and promote the value</h1>
<p>To extract and promote the value we use an old fashion pipeline component using the following code in the execute method (the complete project is part of the <a href="http://www.richardhallgren.com/blogfiles/CustomWCFProperties.zip" target="_blank">downloadable sample project</a>).</p>
</p>
<div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:5ad57ba1-51bc-4d4d-a29e-20f827ede0e3" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;;overflow: auto;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #000000; ">        </span><span style="color: #0000FF; ">public</span><span style="color: #000000; "> IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
        {
            StringReader reader </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> StringReader(inmsg.Context.Read(</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">WindowsUserName</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">, </span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">http://CustomWCFProperties.Schema</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">).ToString());

            </span><span style="color: #0000FF; ">if</span><span style="color: #000000; "> (reader </span><span style="color: #000000; ">!=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">null</span><span style="color: #000000; ">)
            {
                XPathDocument document </span><span style="color: #000000; ">=</span><span style="color: #000000; "> </span><span style="color: #0000FF; ">new</span><span style="color: #000000; "> XPathDocument(reader);
                XPathNavigator navigator </span><span style="color: #000000; ">=</span><span style="color: #000000; "> document.CreateNavigator();
                </span><span style="color: #0000FF; ">string</span><span style="color: #000000; "> value </span><span style="color: #000000; ">=</span><span style="color: #000000; "> navigator.SelectSingleNode(</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">/</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">).Value;
                inmsg.Context.Promote(</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">WindowsUserName</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">, </span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">http://CustomWCFProperties.Schema</span><span style="color: #000000; ">&quot;</span><span style="color: #000000; ">, value);
            }

            </span><span style="color: #0000FF; ">return</span><span style="color: #000000; "> inmsg;
        }</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>All the component does is reading the XML node the value exists inside and then it reads the actual value. Finally it writes the value back and promotes it. To be able to promote the value we also have to have a <a href="http://msdn2.microsoft.com/en-us/library/aa561059.aspx" target="_blank">Property Schema</a> deployed with a corresponding property name and namespace (WindowsUser and <em>http://CustomeWCFProperties.Schema</em> in this case).</p>
<p>The end results looks something like this.</p>
<p><a href="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4message-promoted-username-2.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="206" alt="Message Promoted Username" src="http://www.richardhallgren.com/wp-content/uploads/2008/04/windowslivewriterwritingbiztalkcontextpropertiestoamessag-72f4message-promoted-username-thumb.jpg" width="504" border="0" /></a> </p>
<p>The username is extracted and promoted and available for example for tracking or to for example use in a routing scenario. </p>
<p>This technique could of course be used for all kinds of scenarios where you like to add information to the context properties and could potentially replace a lot of the classic scenarios for custom pipelines.</p>
<p>All kind of comments are of course more than welcome!</p>
<p><a href="http://www.richardhallgren.com/blogfiles/CustomWCFProperties.zip" target="_blank">Download the sample solution&#160; here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardhallgren.com/writing-biztalk-context-properties-to-a-message-from-a-wcf-service-using-behaviors/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
