<?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>Nick Heppleston's BizTalk Blog &#187; Pipeline Components</title>
	<atom:link href="http://www.modhul.com/category/pipeline-components/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.modhul.com</link>
	<description>Experiences of a UK BizTalk Consultant</description>
	<lastBuildDate>Sun, 13 Mar 2011 17:01:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Accouncing the New BizTalk Message Archiving Pipeline Component</title>
		<link>http://www.modhul.com/2009/12/08/accouncing-the-new-biztalk-message-archiving-pipeline-component/</link>
		<comments>http://www.modhul.com/2009/12/08/accouncing-the-new-biztalk-message-archiving-pipeline-component/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 14:24:45 +0000</pubDate>
		<dc:creator>Nick Heppleston</dc:creator>
				<category><![CDATA[Atomic-Scope]]></category>
		<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[BizTalk 2009]]></category>
		<category><![CDATA[Pipeline Components]]></category>
		<category><![CDATA[Archiving]]></category>
		<category><![CDATA[Pipeline Component]]></category>

		<guid isPermaLink="false">http://www.modhul.com/?p=1409</guid>
		<description><![CDATA[It gives me great pleasure to announce Version 1.0 of the BizTalk Message Archiving Pipeline Component and my new venture, Atomic-Scope. The component allows you to archive Xml, flat-file, EDI and binary messages as they pass thru receive and send pipelines, without the need for complex &#8216;archiving&#8217; Send Port configurations, additional load on the MessageBox [...]]]></description>
			<content:encoded><![CDATA[<p>It gives me great pleasure to announce Version 1.0 of the <strong>BizTalk Message Archiving Pipeline Component</strong> and my new venture, <a title="Atomic-Scope" href="http://www.atomic-scope.com" target="_blank">Atomic-Scope</a>.</p>
<p>The component allows you to archive Xml, flat-file, EDI and binary messages as they pass thru receive and send pipelines, without the need for complex &#8216;archiving&#8217; Send Port configurations, additional load on the MessageBox database and requires zero developer time &#8211; just plug-in, configure and use! Archive filenames are created at <em>runtime </em>from Context-Properties written to the message by receive adapters, custom properties defined in your solution or with the standard Send Port &#8216;macros&#8217;. <strong><a title="Download BizTalk Message Archiving Pipeline Component Trial" href="http://www.atomic-scope.com/downloadtrial/?t=1c8ddf2c-bb09-46eb-8b9d-7697558a4b60" target="_blank"> A free 14-day trial is available &#8211; download your copy now.</a></strong></p>
<p>This new version of the component builds on the excellent feedback received following the launch of the original version on Codeplex and has spent many months in development &#8211; this release is a complete re-write and incorporates many of the community requested features, including:</p>
<ul>
<li>The ability to enable and disable the component at runtime;</li>
<li>The promotion of the archive filename into the Message Context for use in orchestrations, Send Port filters etc.;</li>
<li>Full streaming support, even for messages that fail when being processed by downstream components (such as flat-file or EDI messages);</li>
<li>Support for a wide-range of adapter Context-Properties &#8216;out-of-the-box&#8217; and custom, user-defined Context-Properties;</li>
<li>Native 32- and 64-bit versions;</li>
<li>Support for all versions of BizTalk Server 2006, BizTalk Server 2006 R2 &amp; BizTalk Server 2009;</li>
</ul>
<p>The component is also backed by our business-class <a href="http://www.atomic-scope.com/purchase/purchase.php">Enterprise Support Agreement</a>. You can also read more about <a href="http://www.atomic-scope.com/blog/">Atomic-Scope</a> and see how we are supported by the <a title="Microsoft BizSpark" href="http://www.microsoft.com/BizSpark/">Microsoft BizSpark Programme</a>.</p>
<p>A short video if available which gives an overview of how the component works when archiving files in receive pipelines (opens in a new window):</p>
<p><a href="http://www.atomic-scope.com/videos/archiving-component-intro/archiving-component-intro.swf"></a></p>
<p><a href="http://www.atomic-scope.com/videos/archiving-component-intro/archiving-component-intro.swf"><img class="aligncenter" title="Atomic-Scope: An Introduction to the BizTalk Message Archiving Pipeline Component" src="http://www.atomic-scope.com/style/images/atomicscope-videoimage.png" alt="" width="493" height="200" /></a></p>
<p>I plan on posting more information about the Message Archiving Component over the coming weeks. In the meantime, why not <a title="Download BizTalk Message Archiving Pipeline Component Trial" href="http://www.atomic-scope.com/downloadtrial/?t=484a8111-c0d5-42e5-962c-617989618c31" target="_blank">download the component and try it out yourself?</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.modhul.com/2009/12/08/accouncing-the-new-biztalk-message-archiving-pipeline-component/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Handling a Web-Service Null Response: The &#8216;CreateBodyPart&#8217; Pipeline Component</title>
		<link>http://www.modhul.com/2009/03/11/handling-a-web-service-null-response-the-createbodypart-pipeline-component/</link>
		<comments>http://www.modhul.com/2009/03/11/handling-a-web-service-null-response-the-createbodypart-pipeline-component/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 12:15:39 +0000</pubDate>
		<dc:creator>Nick Heppleston</dc:creator>
				<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[Codeplex]]></category>
		<category><![CDATA[Pipeline Components]]></category>
		<category><![CDATA[body part]]></category>
		<category><![CDATA[Microsoft BizTalk Server]]></category>
		<category><![CDATA[MIME]]></category>
		<category><![CDATA[null response]]></category>
		<category><![CDATA[SOAP]]></category>

		<guid isPermaLink="false">http://www.modhul.com/?p=763</guid>
		<description><![CDATA[Originally posted by Nick Heppleston at: http://www.modhul.com/2009/03/11/handling-a-web-service-null-response-the-createbodypart-pipeline-component/ Today I&#8217;m releasing a small component that addresses an interesting problem I&#8217;ve never come across before &#8211; a null response from a web-service. The web-service in question is provided by a third-party and unfortunately cannot be changed. Their WSDL defines the root response element with a maxOccurs=1 and [...]]]></description>
			<content:encoded><![CDATA[<p><em>Originally posted by Nick Heppleston at: <a title="Handling a Web-Service Null Response: The ‘CreateBodyPart’ Pipeline Component" href="http://www.modhul.com/2009/03/11/handling-a-web-service-null-response-the-createbodypart-pipeline-component/" target="_blank">http://www.modhul.com/2009/03/11/handling-a-web-service-null-response-the-createbodypart-pipeline-component/</a><br />
</em></p>
<p><em></em>Today I&#8217;m releasing a small component that addresses an interesting problem I&#8217;ve never come across before &#8211; a null response from a web-service.</p>
<p>The web-service in question is provided by a third-party and unfortunately cannot be changed. Their WSDL defines the root response element with a <em>maxOccurs=1</em> and a <em>minOccurs=0</em>, which allows for a null response to be returned. So instead of a result element with no child nodes as I would expect (below in green):<!-- code formatted by http://manoli.net/csharpformat/ --><br />
<!--<br />
.csharpcode, .csharpcode pre<br />
{<br />
font-size: small;<br />
color: black;<br />
font-family: Consolas, "Courier New", Courier, Monospace;<br />
background-color: #ffffff;<br />
/*white-space: pre;*/<br />
}</p>
<p>.csharpcode pre { margin: 0em; }</p>
<p>.csharpcode .rem { color: #008000; }</p>
<p>.csharpcode .kwrd { color: #0000ff; }</p>
<p>.csharpcode .str { color: #006080; }</p>
<p>.csharpcode .op { color: #0000c0; }</p>
<p>.csharpcode .preproc { color: #cc6633; }</p>
<p>.csharpcode .asp { background-color: #ffff00; }</p>
<p>.csharpcode .html { color: #800000; }</p>
<p>.csharpcode .attr { color: #ff0000; }</p>
<p>.csharpcode .alt<br />
{<br />
background-color: #f4f4f4;<br />
width: 100%;<br />
margin: 0em;<br />
}</p>
<p>.csharpcode .lnum { color: #606060; }<br />
--></p>
<pre class="csharpcode"><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">="1.0"</span> <span class="attr">encoding</span><span class="kwrd">="UTF-8"</span>?<span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">soapenv:Envelope</span> <span class="attr">xmlns:soapenv</span><span class="kwrd">="..."</span> <span class="attr">xmlns:xsd</span><span class="kwrd">="..."</span> <span class="attr">xmlns:xsi</span><span class="kwrd">="..."</span><span class="kwrd">&gt;</span>
 <span class="kwrd">&lt;</span><span class="html">soapenv:Body</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">GetPendingSalesOrdersResponse</span><span class="kwrd">&gt;</span>
    <span style="color:green">&lt;PendingSalesOrdersResult xmlns="..." /&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">GetPendingSalesOrdersResponse</span><span class="kwrd">&gt;</span>
 <span class="kwrd">&lt;/</span><span class="html">soapenv:Body</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">soapenv:Envelope</span><span class="kwrd">&gt;</span></pre>
<p>we&#8217;re receiving an empty response (note the lack of an element between the <em>&lt;GetPendingSalesOrdersResponse&gt;</em> element):</p>
<pre class="csharpcode"><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">="1.0"</span> <span class="attr">encoding</span><span class="kwrd">="UTF-8"</span>?<span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">soapenv:Envelope</span> <span class="attr">xmlns:soapenv</span><span class="kwrd">="..."</span> <span class="attr">xmlns:xsd</span><span class="kwrd">="..."</span> <span class="attr">xmlns:xsi</span><span class="kwrd">="..."</span><span class="kwrd">&gt;</span>
 <span class="kwrd">&lt;</span><span class="html">soapenv:Body</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">GetPendingSalesOrdersResponse</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">GetPendingSalesOrdersResponse</span><span class="kwrd">&gt;</span>
 <span class="kwrd">&lt;/</span><span class="html">soapenv:Body</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">soapenv:Envelope</span><span class="kwrd">&gt;</span></pre>
<p>When the SOAP adapter receives this null response, it creates a message but neglects to create a body part &#8211; I presume this is because there is nothing to create it from. As a result, the message fails in both an XmlReceive and PassThruReceive pipeline; when using the PassThruReceive pipeline, the XLANG/s engine throws the following error when it tries to read the body part:</p>
<blockquote><p><em>The XLANG/s message has no part at index &#8217;0&#8242;.  The total number of parts found in the message is &#8217;0&#8242;. If you expect a multipart message, check that the pipeline supports multipart messages such as MIME</em>.</p></blockquote>
<p>To address this problem, I&#8217;ve created a very simple receive pipeline component which lives on the receive side of the web-service solicit-response port and interrogates a message to determine whether it has a message body. If a message body is not present, it creates one based on the component properties (which mimic the expected &#8211; valid &#8211; response from the web-service) allowing the response message to be passed into the Message Box without issue. It a message body is present, it passes the message through unchanged.</p>
<p><strong>The CreateBodyPart Pipeline Component</strong></p>
<p>The component lives in the Decode stage of the receive pipeline and simply detects for the presence of a message body. If the body part is null, a new message part is created using the component properties <em>BodyPartName</em> and <em>BodyPartContent </em>and assigned as the body part of the message, before being passed onto the next stage of the pipeline. The BodyPartName and BodyPartContent properties specify the name of the body part and the Xml you want the part to contain &#8211; given that the content of the message is likely to be small-ish (i.e. <em>&lt;PendingSalesOrdersResult xmlns=&#8221;&#8230;&#8221; /&gt;</em> in the example above).</p>
<p>There are a few enhancements that I can envisage for this component already, including the ability to specify whether the part should be a body part &#8211; you might just want to create extra parts on the fly, not just a body part; and also the ability to specify the encoding and character set being used with your part content. However, I&#8217;ll leave these enhancements for a later day.</p>
<p>You can find binaries and source for the component at Codeplex: <a title="BizTalk 2006 Create Body Part Pipeline Component" href="http://btscreatebdyprtcomp.codeplex.com/" target="_blank">http://btscreatebdyprtcomp.codeplex.com/</a></p>
<p>As a final note, my client is currently running BizTalk 2006 (not R2) and we are running on the out-of-box SOAP adapter. Does anyone know whether this issue is a problem in the WCF-SOAP adapter or the WSE adapter?</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/d3e2c0b8-f38c-46f7-826e-11314a4dc9b8/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=d3e2c0b8-f38c-46f7-826e-11314a4dc9b8" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.modhul.com/2009/03/11/handling-a-web-service-null-response-the-createbodypart-pipeline-component/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Writing Unit Tests for Pipeline Components with NCover</title>
		<link>http://www.modhul.com/2008/10/27/writing-unit-tests-for-pipeline-components-with-ncover/</link>
		<comments>http://www.modhul.com/2008/10/27/writing-unit-tests-for-pipeline-components-with-ncover/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 13:34:44 +0000</pubDate>
		<dc:creator>Nick Heppleston</dc:creator>
				<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[Pipeline Components]]></category>
		<category><![CDATA[BizTalk]]></category>
		<category><![CDATA[NCover]]></category>
		<category><![CDATA[Pipeline Component]]></category>
		<category><![CDATA[Pipeline Testing]]></category>

		<guid isPermaLink="false">http://www.modhul.com/?p=347</guid>
		<description><![CDATA[I discovered NCover over the weekend and wow, am I a fan! NCover is a code coverage tool which, to quote the website, &#8220;helps you test intelligently by revealing which tests haven&#8217;t been written yet.&#8221; In laymans terms, NCover graphically shows you which lines of code were not touched during the execution of your unit [...]]]></description>
			<content:encoded><![CDATA[<p>I discovered <a href="http://www.ncover.com/" target="_blank">NCover</a> over the weekend and wow, am I a fan!</p>
<p>NCover is a code coverage tool which, to quote the website, &#8220;helps you <span class="highlight">test intelligently</span> by revealing which tests haven&#8217;t been written yet.&#8221; In laymans terms, NCover graphically shows you which lines of code were not touched during the execution of your unit tests, allowing you to create tests accordingly to achieve 100% code coverage, as shown below:</p>
<p><a href="http://www.modhul.com/wp-content/uploads/2008/10/soclose_nce_screenshot.jpg"><img class="aligncenter size-full wp-image-348" title="NCover Explorer Screenshot" src="http://www.modhul.com/wp-content/uploads/2008/10/soclose_nce_screenshot.jpg" alt="" width="607" height="142" /></a></p>
<p><strong>Pipeline Component Testing</strong></p>
<p>Armed with <a href="http://www.winterdom.com/weblog/" target="_blank">Tomas Restrepo&#8217;s</a> excellent <a href="http://github.com/tomasr/pipelinetesting/tree/master" target="_self">Pipeline Testing library</a>, we can now comprehensively test our Pipeline Components:</p>
<p>1. Develop units tests to test your pipeline and ensure that the tests execute and are successful;</p>
<p>2. Invoke your testing framework from the command line to check that your tests will run correctly in the NCover environment (I&#8217;m using NUnit here, but you could also invoke VSTS):</p>
<blockquote><p><strong><code>"C:\Program Files\NUnit 2.4.8\bin\nunit-console.exe" BizTalkMessageArchivingComponent.Tests.dll</code></strong></p></blockquote>
<p>Which should produce the following output on the command line:</p>
<p><a href="http://www.modhul.com/wp-content/uploads/2008/10/nunit-commandline-output.png"><img class="aligncenter size-full wp-image-354" title="nunit-commandline-output" src="http://www.modhul.com/wp-content/uploads/2008/10/nunit-commandline-output.png" alt="" width="665" height="299" /></a></p>
<p>3. With our unit tests successfully executing, we can wrap the NUnit invocation in NCover loveliness which will inspect our code coverage while those tests executed:</p>
<blockquote><p><code><strong>ncover.console</strong> "C:\Program Files\NUnit 2.4.8\bin\nunit-console.exe" BizTalkMessageArchivingComponent.Tests.dll <strong>//ea Modhul.BizTalk.Pipelines.ArchiveMessages.Attributes.NCoverExcludeCoverage //et "Winterdom.*;BizTalkMessageArchivingComponent.Tests.*"</strong></code></p></blockquote>
<p>Producing command-line output similar to the following (notice the NUnit tests running between the <em>***Program Output***</em> and <em>***End Program Output***</em> text):</p>
<p><a href="http://www.modhul.com/wp-content/uploads/2008/10/ncover-commandline-output.png"><img class="aligncenter size-full wp-image-360" title="ncover-commandline-output" src="http://www.modhul.com/wp-content/uploads/2008/10/ncover-commandline-output.png" alt="" width="665" height="563" /></a></p>
<p>NCover has now determined the code coverage based of your unit tests and produces a <strong>Coverage.Xml</strong> file. This file contains information relating to the code coverage and can be loaded in the NCover.Explorer tool to produce a VS like environment that displays lines of code that were touched and un-touched by your unit tests.</p>
<p>4. Load the NCover.Explorer tool and open the Coverage.Xml file generated above, you will be presented with a screen detailing your code coverage. In the example below, you can see that the <strong>PerformImmediateCopy</strong> and <strong>StreamOnReadEvent </strong>methods do not have full code coverage &#8211; both have code which was not executed in our unit tests:</p>
<p><a href="http://www.modhul.com/wp-content/uploads/2008/10/ncoverexplorer-codecoverage-treeview.png"><img class="aligncenter size-full wp-image-364" title="ncoverexplorer-codecoverage-treeview" src="http://www.modhul.com/wp-content/uploads/2008/10/ncoverexplorer-codecoverage-treeview.png" alt="" width="385" height="338" /></a></p>
<p>Clicking on one of the methods in the tree view loads the offending method, displaying the lines which were not executed by our tests in red; lines that were executed are displayed in blue:</p>
<p><a href="http://www.modhul.com/wp-content/uploads/2008/10/ncoverexplorer-codecoverage-codeview.png"><img class="aligncenter size-full wp-image-367" title="ncoverexplorer-codecoverage-codeview" src="http://www.modhul.com/wp-content/uploads/2008/10/ncoverexplorer-codecoverage-codeview.png" alt="" width="550" height="614" /></a></p>
<p>Based on this information, we can now create tests to cater for these exceptions, ensuring we have 100% code coverage.</p>
<p>NCover is an excellent tool and although it isn&#8217;t free, I personally think its a must-have for any developers tool-kit.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.modhul.com/2008/10/27/writing-unit-tests-for-pipeline-components-with-ncover/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>BizTalk 2006 Message Archiving Component &#8211; More Efficient Stream Handling</title>
		<link>http://www.modhul.com/2008/03/25/biztalk-2006-message-archiving-component-more-efficient-stream-handling/</link>
		<comments>http://www.modhul.com/2008/03/25/biztalk-2006-message-archiving-component-more-efficient-stream-handling/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 14:04:05 +0000</pubDate>
		<dc:creator>Nick Heppleston</dc:creator>
				<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[Pipeline Components]]></category>
		<category><![CDATA[BizTalk]]></category>
		<category><![CDATA[Message Archiving]]></category>
		<category><![CDATA[Pipeline Component]]></category>

		<guid isPermaLink="false">http://www.modhul.com/2008/03/25/biztalk-2006-message-archiving-component-more-efficient-stream-handling/</guid>
		<description><![CDATA[Update: The Message Archiving Component is now maintained by Atomic-Scope, visit http://www.atomic-scope.com/downloadtrial for more information. I&#8217;ve re-worked the BizTalk 2006 Message Archiving Component as a true streaming pipeline component &#8211; utilising a forward only eventing stream &#8211; to more efficiently use process resources when archiving large files, as suggested by Mikael Håkansson. The updated version [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> The Message Archiving Component is now maintained by Atomic-Scope, visit <a title="Atomic-Scope: Download Message Archiving Component Trial" href="http://www.atomic-scope.com/downloadtrial" target="_blank">http://www.atomic-scope.com/downloadtrial</a> for more information.</p>
<p>I&#8217;ve re-worked the BizTalk 2006 Message Archiving Component as a <em>true</em> streaming pipeline component &#8211; utilising a forward only eventing stream &#8211; to more efficiently use process resources when archiving large files, as suggested by <a href="http://blogical.se/blogs/mikael">Mikael Håkansson</a>. The updated version is on <a title="BizTalk 2006 Message Archiving Pipeline Component" href="http://www.codeplex.com/btsmsgarchcomp" target="_blank">CodePlex as version 0.3</a>.</p>
<p>Writing of the archive file is now accomplished during the read-event of the FOE stream, essentially spooling the archive file to disk (or network share) as the stream is read by downstream components or the Messaging Agent itself. The BizTalk process memory footprint using this new code-base (while testing with a large (10Mb) message) is 90% more efficient than previous versions.</p>
<p>All other functionality remains unchanged.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.modhul.com/2008/03/25/biztalk-2006-message-archiving-component-more-efficient-stream-handling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Announcing a new BizTalk 2006 Message Archiving Component</title>
		<link>http://www.modhul.com/2008/03/23/announcing-a-new-biztalk-2006-message-archiving-component/</link>
		<comments>http://www.modhul.com/2008/03/23/announcing-a-new-biztalk-2006-message-archiving-component/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 22:13:56 +0000</pubDate>
		<dc:creator>Nick Heppleston</dc:creator>
				<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[Pipeline Components]]></category>
		<category><![CDATA[BizTalk]]></category>
		<category><![CDATA[Message Archiving]]></category>
		<category><![CDATA[Pipeline Component]]></category>

		<guid isPermaLink="false">http://www.modhul.com/2008/03/23/announcing-a-new-biztalk-2006-message-archiving-component/</guid>
		<description><![CDATA[Update: The Message Archiving Component is now maintained by Atomic-Scope, visit http://www.atomic-scope.com/downloadtrial for more information. A couple of days ago I uploaded a revised version of my BizTalk 2006 Message Archiving Component onto CodePlex &#8211; version 0.2 can be downloaded from the CodePlex website at http://www.codeplex.com/btsmsgarchcomp. The component works with BizTalk 2006 &#38; BizTalk 2006 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> The Message Archiving Component is now maintained by Atomic-Scope, visit <a title="Atomic-Scope: Download Message Archiving Component Trial" href="http://www.atomic-scope.com/downloadtrial" target="_blank">http://www.atomic-scope.com/downloadtrial</a> for more information.</p>
<p>A couple of days ago I uploaded a revised version of my BizTalk 2006 Message Archiving Component onto CodePlex &#8211; version 0.2 can be downloaded from the CodePlex website at <a title="BizTalk 2006 Message Archiving Pipeline Component" href="http://www.codeplex.com/btsmsgarchcomp" target="_blank">http://www.codeplex.com/btsmsgarchcomp</a>.</p>
<p>The component works with BizTalk 2006 &amp; BizTalk 2006 R2 and allows messages to be written to the file system (either locally or over a network share) for archiving, using message context-properties to define the archive path. It is written in a streaming fashion, is designed for large message consumption and can handle Xml, binary and flat-files.</p>
<p>The component can be executed in either the Decode (receive pipeline) or Encode (send pipeline) stages &#8211; when used on the receive side, the original message can be archived before BizTalk has started to manipulate the message; on the send side, the final message before delivery via the send adapter can be captured. If message archiving fails, the message will still continue downstream.</p>
<p>As per the <a title="Message Archiving Receive Pipeline Component" href="http://www.modhul.com/2007/04/26/message-archiving-receive-pipeline-component/" target="_blank">previous version</a>, the archive path is constructed using &#8216;macros&#8217; (e.g. <strong>%ReceivePortName%</strong>) which relate to message Context Properties. In the previous version, these macro&#8217;s were hard-coded into the component so changing or adding a new macro was painful, requiring a rebuild of the code base. The new version continues the theme of macros, however they have moved into an Xml configuration file, which can be configured at run-time, allowing any context-property (either a known BizTalk context property or a custom adapter/pipeline property) to be used. An example of the configuration file is shown below:</p>
<p><img src="http://www.modhul.com/wp-content/uploads/2008/03/macrodefinitionfilesample.PNG" alt="Macro Definition File Sample" /></p>
<p>These macros are used when defining the archive file path in the component configuration (in the BizTalk Server Admin Console) &#8211; see the screenshot below. The archive file path is constructed using the <strong>ArchiveDirectory</strong> and <strong>ArchiveFilename</strong> properties. Macros can be repeated and/or used in both properties at the same time (however I can think of scenarios where you may not wish to use say ReceivePortName in the archive filename).</p>
<p><strong>Note:</strong> When configuring the component properties, you are specifing the macro name, not the context property name. This is useful when you are using a single configuration file and want to read the ReceivedFileName context property from both the FTP and FILE adapters for example (both use the same property name, but different property namespaces) &#8211; in this scenario, you would call the macro&#8217;s &#8216;ReceivedFileNameFILE&#8217; and &#8216;ReceivedFileNameFTP&#8217; to avoid ambiguity.</p>
<p>The example Macro Definition Xml file shown above details macros for the System Context Properties ReceivePortName and ReceiveLocationName. To use these macros in the pipeline component, assign them in the <strong>Archive Directory</strong> or <strong>Archive Filename</strong> property, as below.</p>
<p><img src="http://www.modhul.com/wp-content/uploads/2008/03/componentconfig-macroexamples-new.PNG" alt="Component Configuration - Macro Examples" align="left" /> These macro&#8217;s (<strong>%ReceivePortName%</strong>, <strong>%ReceiveLocationName%</strong> and <strong>%MessageID%</strong>) will be expanded as a message is delivered via the port to their real-world values, writing the archived message to (for example):</p>
<blockquote><p><strong>..\Test Xml Dasm Decode Stage\Test Xml Dasm Decode Stage Location\364a4dee-c698-4ddd-af14-d44e66f3bd5d.xml</strong></p></blockquote>
<p>In the example above we&#8217;re using the %MessageID% macro to build the archive filename. This is a special macro as the value does not come from the message Context, but is taken directly from the message itself, similar to using %MessageID%.xml in a Send FILE adapter.</p>
<p>The <strong>OverwriteExistingFile</strong> property indicates to the component whether an existing file should be overwritten if, once the archive path has been constructed from the Context Property macros, the full archive path resolves to an existing file. If set to <strong>true</strong>, the existing file will be overwritten; if <strong>false</strong>, the new file will be written to the same directory, but with an additional GUID before the file extension.</p>
<p>Finally, the <strong>MacroDefinitionsFile </strong>property defines the location to the Xml configuration file detailing the macro Context Property substitutions. A different file can be used per pipeline, or a single global file can be used. A more detailed example than that shown above &#8211; which includes macro&#8217;s for commonly used Message Tracking, System and File adapter properties &#8211; <a title="Sample Macro Definitions File" href="http://www.modhul.com/wp-content/uploads/2008/03/macrosdefinitions.xml" target="_blank">is available to download</a>.</p>
<p>With regards to <strong>permissions</strong>, you will need to ensure that the user running the BizTalk service has <em>read </em>permissions on the macro definitions Xml configuration file and <em>read/write</em> permissions on the root of the archive directory.</p>
<p>Although the component is production ready it is not yet feature complete. If you are using the previous version, can I ask you to<a title="BizTalk 2006 Message Archiving Pipeline Component - Releases" href="http://www.codeplex.com/btsmsgarchcomp/Release/ProjectReleases.aspx" target="_blank"> download a copy</a> and try it out &#8211; please let me have any feedback via the comments on this post, or via the <a title="BizTalk 2006 Message Archiving Pipeline Component - Issue Tracker" href="http://www.codeplex.com/btsmsgarchcomp/WorkItem/List.aspx" target="_blank">Issue Tracker pages</a> of the CodePlex project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.modhul.com/2008/03/23/announcing-a-new-biztalk-2006-message-archiving-component/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Testing Pipeline Components &#8211; The Pipeline Testing Library</title>
		<link>http://www.modhul.com/2008/03/11/testing-pipeline-components-the-pipeline-testing-library/</link>
		<comments>http://www.modhul.com/2008/03/11/testing-pipeline-components-the-pipeline-testing-library/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 14:10:27 +0000</pubDate>
		<dc:creator>Nick Heppleston</dc:creator>
				<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[Pipeline Components]]></category>
		<category><![CDATA[Archive]]></category>
		<category><![CDATA[Pipeline Component]]></category>
		<category><![CDATA[Pipeline Testing]]></category>

		<guid isPermaLink="false">http://www.modhul.com/2008/03/11/testing-pipeline-components-the-pipeline-testing-library/</guid>
		<description><![CDATA[I&#8217;ve spent some time recently working almost exclusively with BizTalk pipeline components and took the opportunity to use the excellent Pipeline Testing Library produced by Tomas Restrepo (more info is available here and here). If Microsoft were writing this post, they would probably say that &#8216;It Rocks!&#8217;. I&#8217;m British, so I&#8217;ll be a little more [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent some time recently working almost exclusively with BizTalk pipeline components and took the opportunity to use the excellent <a title="Pipeline Testing Library" href="http://www.winterdom.com/weblog/2007/08/09/PipelineTesting11Released.aspx" target="_blank">Pipeline Testing Library</a> produced by Tomas Restrepo (more info is available <a title="Pipeline Testing Library Part 1" href="http://www.winterdom.com/weblog/2006/04/27/PipelineTestingLibraryPart1.aspx" target="_blank">here</a> and <a title="Testing Pipeline Components" href="http://www.winterdom.com/weblog/2006/04/24/TestingPipelineComponents.aspx" target="_blank">here</a>). If Microsoft were writing this post, they would probably say that &#8216;It Rocks!&#8217;. I&#8217;m British, so I&#8217;ll be a little more reserved and simply say that, imho, this is the single best tool for developing and testing custom pipeline components, period.</p>
<p>The library provides a framework for unit-testing components in the standard NUnit or MSTest manner, without having to go to Pipeline.exe or doing a full deployment to a BizTalk instance itself &#8211; both of which aren&#8217;t particularly quick or agile. Furthermore, the library lets you seamlessly integrate with MSBuild, without jumping through lots of hoops to get a similar effect.</p>
<p>The library allows you to programatticaly create pipelines, create instances of components and assign them to their respective stages (including your own custom components and the familiar out-of-the-box components), or load an existing BizTalk pipeline without the need to deploy the supporting BizTalk project.</p>
<p>A very simple example from my recent testing looks something like the following:</p>
<p><img src="http://www.modhul.com/wp-content/uploads/2008/03/pipelinetestingexample-xmldasm.PNG" alt="Pipeline Testing Example - Xml Disassembler" /></p>
<p>Here, I&#8217;m creating an instance of my archiving component (the component I&#8217;m testing) and the Xml Disassembler (specifying the document type it should accept). I create a new receive pipeline and assign the archiving component to the decode stage and the XmlDasm to the disassembler stage. After creating a sample message using the MessageHelper helper, I add context properties that mimic the adapter I&#8217;m trying to test (in this case the FILE adapter) and execute the pipeline. I finally test to check that the archiving component wrote the file to the archive in the expected location, with the expected filename.</p>
<p>If you want to test using Flat-Files, simply use a flat-file disassembler and specify the schema:</p>
<p><img src="http://www.modhul.com/wp-content/uploads/2008/03/pipelinetestingexample-ffdasm-snippet.PNG" alt="Pipeline Testing Example - Flat-File Disassembler Snippet" /></p>
<p>Powerful stuff &#8211; no more long-winded MSBuild tasks to deploy your solution, configure several possible adapters and push messages to those adapters over different protocols, simply to test a custom pipeline component on your development workstation (and lose 5-10 minutes in the process). Don&#8217;t get me wrong, all this should be happening in your smoke and UAT environments, but for the developer (attempting) to work in an agile manner on a BizTalk project, Tomas&#8217; Pipeline Testing library is priceless.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.modhul.com/2008/03/11/testing-pipeline-components-the-pipeline-testing-library/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Generating Microsoft Word Documents Natively using BizTalk 2006</title>
		<link>http://www.modhul.com/2008/01/17/generating-microsoft-word-documents-natively-using-biztalk-2006/</link>
		<comments>http://www.modhul.com/2008/01/17/generating-microsoft-word-documents-natively-using-biztalk-2006/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 13:52:28 +0000</pubDate>
		<dc:creator>Nick Heppleston</dc:creator>
				<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[Pipeline Components]]></category>

		<guid isPermaLink="false">http://www.modhul.com/2008/01/17/generating-microsoft-word-documents-natively-using-biztalk-2006/</guid>
		<description><![CDATA[In this post I&#8217;ll discuss how to generate Word 2007 documents natively from BizTalk 2006 using the Office Open Xml System.IO.Packaging API recently released by the Microsoft Office Team under .Net 3.0. Background Unless you&#8217;ve lived under a rock during the last year, you&#8217;ll know that the Office Open XML (OOXML) format is the new [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I&#8217;ll discuss how to generate Word 2007 documents natively from BizTalk 2006 using the Office Open Xml System.IO.Packaging API recently released by the Microsoft Office Team under .Net 3.0.</p>
<p><strong>Background</strong></p>
<p>Unless you&#8217;ve lived under a rock during the last year, you&#8217;ll know that the Office Open XML (OOXML) format is the new Xml format for the Office 2007 suite, namely Word, Excel and Powerpoint. OOXML uses a file package conforming to the <a href="http://en.wikipedia.org/wiki/Open_Packaging_Convention" title="Open Packaging Convention">Open Packaging Convention</a> and contains a number of individual files that form the basis of the document; the package is then zipped to reduce the overall size of the resulting file (either a .docx, .xlsx or .pptx).</p>
<p><strong>Generating Word Documents &#8211; Overview</strong></p>
<p>Generating a Word document is relatively simple and only requires a custom send pipeline component that generates our OOXML package.</p>
<p>In this post I will be using a Sales Report scenario, generating a Word document from the output of a fictional ERP system; to that extent, I&#8217;ll also be mapping from a fictional sales summary Xml message to the required OOXML format before generating the final .docx. The final document will look something like the following (note that the areas in red will be replaced with content from our ERP sales summary message &#8211; click on the image for a larger version):</p>
<p><center><a href="http://www.modhul.com/wp-content/uploads/2008/01/proposedsalessummarydocument.PNG"><img src="http://www.modhul.com/wp-content/uploads/2008/01/proposedsalessummarydocument_small.png" alt="Proposed Sales Summary Document - Small" border="0" /></a></center>Before we start, I need to present a quick crash-course in the structure of OOXML packages. A minimal OOXML WordprocessingML document contains three parts: a part that defines the main document body, usually called <em>document.xml</em>; a part detailing the Content Types (which indicates to the consumer what type of content can be expected in the package); and a Relationships part (which ties the document parts and Content Types together). When using the System.IO.Packaging API we only need to concern ourselves with the main document body &#8211; the API takes care of creating the Content Types and Relationship parts. Its this feature of the API that allows us to create Word documents in BizTalk &#8211; all we need to do is create the Xml for the main document and squirt it at a custom pipeline component which does the packaging stuff for us using the API.</p>
<p>Note that the structure of an OOXML document is outside of the scope of this post (but a good understanding is fundamental when working with these documents) and I would recommend that you read the excellent <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=6f264d0b-23e8-43fe-9f82-9ab627e5eaa3&amp;displaylang=en" title="2007 Office Document: Open XML Markup Explained" target="_blank">Open Xml Markup Explained</a> by Wouter van Vugt.</p>
<p><strong>Generating Word Documents &#8211;  The &#8216;Main&#8217; Document</strong></p>
<p>The main document body (i.e. document.xml) is the only part that is generated in the BizTalk solution. We don&#8217;t actually create a file called <em>document.xml</em> &#8211; the packaging API does this for us &#8211; instead we simply create a message that conforms to the OOXML schema and pass this into the custom Send pipeline.</p>
<p>In our scenario, we are generating a Sales Report document for distribution to the finance department &#8211; we will receive an Xml sales summary document from our fictional ERP system that resembles the following:</p>
<blockquote><p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="csharpcode">
<span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">="1.0"</span> <span class="attr">encoding</span><span class="kwrd">="utf-8"</span>?<span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">ns0:SalesReport</span> <span class="attr">xmlns:ns0</span><span class="kwrd">="http://schemas.modhul.com/erp/salesreport-1.0"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Author</span><span class="kwrd">&gt;</span>Nick Heppleston<span class="kwrd">&lt;/</span><span class="html">Author</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Email</span><span class="kwrd">&gt;</span>nick@modhul.com<span class="kwrd">&lt;/</span><span class="html">Email</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">SalesStart</span><span class="kwrd">&gt;</span>10th January 2008<span class="kwrd">&lt;/</span><span class="html">SalesStart</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">SalesEnd</span><span class="kwrd">&gt;</span>17th January 2008<span class="kwrd">&lt;/</span><span class="html">SalesEnd</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">SalesSummary</span><span class="kwrd">&gt;</span>100,48.00<span class="kwrd">&lt;/</span><span class="html">SalesSummary</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">ns0:SalesReport</span><span class="kwrd">&gt;</span></pre>
</blockquote>
<p>which needs to be mapped into our OOXML main document body message (I think the layout of the OOXML message is pretty self explanatory, however I would point you at <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=6f264d0b-23e8-43fe-9f82-9ab627e5eaa3&amp;displaylang=en" title="2007 Office Document: Open XML Markup Explained" target="_blank">Open Xml Markup Explained</a> if you&#8217;re after a more detailed explanation):</p>
<blockquote><p> <!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="csharpcode">
<span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">="1.0″ encoding="</span><span class="attr">utf-8</span>″ ?<span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">w:document</span> <span class="attr">xmlns:w</span><span class="kwrd">="http://schemas.openxmlformats.org/wordprocessingml/2006/main"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">w:body</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">w:p</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">w:r</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:rPr</span><span class="kwrd">&gt;</span>
                    <span class="kwrd">&lt;</span><span class="html">w:b</span> <span class="kwrd">/&gt;</span>
                    <span class="kwrd">&lt;</span><span class="html">w:sz</span> <span class="attr">w:val</span>="<span class="attr">52</span>″ <span class="kwrd">/&gt;</span>"
                        <span class="kwrd">&lt;</span><span class="html">w:rFonts</span> <span class="attr">w:ascii</span><span class="kwrd">="Cambria"</span> <span class="kwrd">/&gt;</span>
                    <span class="kwrd">&lt;/</span><span class="html">w:rPr</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:t</span> <span class="attr">xml:space</span><span class="kwrd">="preserve"</span><span class="kwrd">&gt;</span>Sales Summary for: <span class="kwrd">&lt;/</span><span class="html">w:t</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:t</span><span class="kwrd">&gt;</span>Nick Heppleston<span class="kwrd">&lt;/</span><span class="html">w:t</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">w:r</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">w:p</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">w:p</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">w:r</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:rPr</span><span class="kwrd">&gt;</span>
                    <span class="kwrd">&lt;</span><span class="html">w:i</span> <span class="kwrd">/&gt;</span>
                    <span class="kwrd">&lt;</span><span class="html">w:sz</span> <span class="attr">w:val</span>="<span class="attr">52</span>″ <span class="kwrd">/&gt;</span>"
                        <span class="kwrd">&lt;</span><span class="html">w:rFonts</span> <span class="attr">w:ascii</span><span class="kwrd">="Cambria"</span> <span class="kwrd">/&gt;</span>
                        <span class="kwrd">&lt;</span><span class="html">w:spacing</span> <span class="attr">w:val</span>="<span class="attr">15</span>″ <span class="kwrd">/&gt;</span>"
                        <span class="kwrd">&lt;</span><span class="html">w:color</span> <span class="attr">w:val</span>="<span class="attr">48FDB2</span>″ <span class="kwrd">/&gt;</span>"
                <span class="kwrd">&lt;/</span><span class="html">w:rPr</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:t</span> <span class="attr">xml:space</span><span class="kwrd">="preserve"</span><span class="kwrd">&gt;</span>Sales from: <span class="kwrd">&lt;/</span><span class="html">w:t</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:t</span><span class="kwrd">&gt;</span>10th January 2008<span class="kwrd">&lt;/</span><span class="html">w:t</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:t</span> <span class="attr">xml:space</span><span class="kwrd">="preserve"</span><span class="kwrd">&gt;</span> to <span class="kwrd">&lt;/</span><span class="html">w:t</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:t</span><span class="kwrd">&gt;</span>17th January 2008<span class="kwrd">&lt;/</span><span class="html">w:t</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:t</span> <span class="attr">xml:space</span><span class="kwrd">="preserve"</span><span class="kwrd">&gt;</span> - <span class="kwrd">&lt;/</span><span class="html">w:t</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:t</span><span class="kwrd">&gt;</span>£100,48.00<span class="kwrd">&lt;/</span><span class="html">w:t</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">w:r</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">w:p</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">w:p</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">w:r</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:t</span> <span class="attr">xml:space</span><span class="kwrd">="preserve"</span><span class="kwrd">&gt;</span>Contact: <span class="kwrd">&lt;/</span><span class="html">w:t</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:t</span><span class="kwrd">&gt;</span>Nick Heppleston<span class="kwrd">&lt;/</span><span class="html">w:t</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:t</span> <span class="attr">xml:space</span><span class="kwrd">="preserve"</span><span class="kwrd">&gt;</span> | <span class="kwrd">&lt;/</span><span class="html">w:t</span><span class="kwrd">&gt;</span>
                <span class="kwrd">&lt;</span><span class="html">w:t</span><span class="kwrd">&gt;</span>nick@modhul.com<span class="kwrd">&lt;/</span><span class="html">w:t</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;/</span><span class="html">w:r</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">w:p</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">w:body</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">w:document</span><span class="kwrd">&gt;</span></pre>
</blockquote>
<p>This transformation can be performed anywhere: in the sample solution I&#8217;ve put the map on the Receive Port. Also, because I can&#8217;t think of any way to generate this type of message using a standard BizTalk Map &#8211; how do I graphically say &#8216;map from this source node to this destination node&#8217; when all of the destination nodes simply repeat themselves &#8211; I am using custom XSLT to drive the map.</p>
<p>Note: I&#8217;ve yet to find a satisfactory XSD for the WordprocessingML markup so the solution contains a OOXML schema that was automagically generated from the above destination format. I&#8217;m working on sourcing the schema &#8211; I have a number of &#8216;feelers&#8217; out with the Office Team and I hope to be able to provide a reference in the next couple of days.</p>
<p>With our Sales Summary message now mapped and in the necessary OOXML format, we can send it to the custom pipeline / pipeline component for it to do its work and generate our .docx package.</p>
<p><code></code><strong>Generating Word Documents &#8211; The Custom Pipeline Component</strong></p>
<p><span style="text-indent: 36pt">The custom pipeline component is relatively simple. It uses the </span>System.IO.Packaging API introduced in .Net 3.0 which can be found in windowsbase.dll (C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\windowsbase.dll); full documentation regarding this namespace can be found <a href="http://msdn2.microsoft.com/en-us/library/system.io.packaging.aspx" title=".NET Framework Class Library - System.IO.Packaging Namespace" target="_blank">online at MSDN</a>. The API is invoked in the pipeline component <span style="text-indent: 36pt">Execute() method as follows:</span></p>
<blockquote><p> <!-- code formatted by http://manoli.net/csharpformat/ --></p>
<p class="csharpcode">
<pre><span class="lnum">   1:  </span><span class="kwrd">public</span> IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)</pre>
<pre><span class="lnum">   2:  </span>{</pre>
<pre><span class="lnum">   3:  </span>    XmlDocument InputXmlDocument = <span class="kwrd">new</span> XmlDocument();</pre>
<pre><span class="lnum">   4:  </span>    InputXmlDocument.XmlResolver = <span class="kwrd">null</span>;</pre>
<pre><span class="lnum">   5:  </span></pre>
<pre><span class="lnum">   6:  </span>    <span class="rem">// Define bodypart instances</span></pre>
<pre><span class="lnum">   7:  </span>    IBaseMessagePart bodyPart = inmsg.BodyPart;</pre>
<pre><span class="lnum">   8:  </span></pre>
<pre><span class="lnum">   9:  </span>    <span class="rem">// Define stream instances</span></pre>
<pre><span class="lnum">  10:  </span>    Stream originalStream = <span class="kwrd">null</span>;</pre>
<pre><span class="lnum">  11:  </span>    MemoryStream odfStream = <span class="kwrd">new</span> MemoryStream();</pre>
<pre><span class="lnum">  12:  </span></pre>
<pre><span class="lnum">  13:  </span>    <span class="kwrd">string</span> docContentType = <span class="str">"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"</span>;</pre>
<pre><span class="lnum">  14:  </span>    <span class="kwrd">string</span> docRelationshipType = <span class="str">"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"</span>;</pre>
<pre><span class="lnum">  15:  </span></pre>
<pre><span class="lnum">  16:  </span>    <span class="kwrd">if</span> (<span class="kwrd">null</span> != bodyPart)</pre>
<pre><span class="lnum">  17:  </span>    {</pre>
<pre><span class="lnum">  18:  </span>        <span class="rem">// Get a *copy* of the original stream</span></pre>
<pre><span class="lnum">  19:  </span>        originalStream = bodyPart.Data;</pre>
<pre><span class="lnum">  20:  </span></pre>
<pre><span class="lnum">  21:  </span>        <span class="rem">// Check that the original stream is not null</span></pre>
<pre><span class="lnum">  22:  </span>        <span class="kwrd">if</span> (<span class="kwrd">null</span> != originalStream)</pre>
<pre><span class="lnum">  23:  </span>        {</pre>
<pre><span class="lnum">  24:  </span>            <span class="rem">// Load the original message stream into our input xml document </span></pre>
<pre><span class="lnum">  25:  </span>            <span class="rem">// to be used as the basis of the OOXML document.</span></pre>
<pre><span class="lnum">  26:  </span>            InputXmlDocument.Load(originalStream);</pre>
<pre><span class="lnum">  27:  </span></pre>
<pre><span class="lnum">  28:  </span>            <span class="kwrd">try</span></pre>
<pre><span class="lnum">  29:  </span>            {</pre>
<pre><span class="lnum">  30:  </span>                <span class="rem">// Create a new OOXML package</span></pre>
<pre><span class="lnum">  31:  </span>                Package pkg = Package.Open(odfStream, FileMode.Create, FileAccess.ReadWrite);</pre>
<pre><span class="lnum">  32:  </span></pre>
<pre><span class="lnum">  33:  </span>                <span class="rem">// Create a Uri for the document part</span></pre>
<pre><span class="lnum">  34:  </span>                Uri docPartUri = <span class="kwrd">new</span> Uri(<span class="str">"/word/document.xml"</span>, UriKind.Relative);</pre>
<pre><span class="lnum">  35:  </span></pre>
<pre><span class="lnum">  36:  </span>                <span class="rem">// Create the document part</span></pre>
<pre><span class="lnum">  37:  </span>                PackagePart mainPart = pkg.CreatePart(docPartUri, docContentType);</pre>
<pre><span class="lnum">  38:  </span></pre>
<pre><span class="lnum">  39:  </span>                <span class="rem">// Add the data from the Xml Document to the document part</span></pre>
<pre><span class="lnum">  40:  </span>                Stream partStream = mainPart.GetStream(FileMode.Create, FileAccess.Write);</pre>
<pre><span class="lnum">  41:  </span>                InputXmlDocument.Save(partStream);</pre>
<pre><span class="lnum">  42:  </span>                partStream.Close();</pre>
<pre><span class="lnum">  43:  </span>                pkg.Flush();</pre>
<pre><span class="lnum">  44:  </span></pre>
<pre><span class="lnum">  45:  </span>                <span class="rem">// Create the relationship between the part and the package.</span></pre>
<pre><span class="lnum">  46:  </span>                PackageRelationship pkgRelationship = pkg.CreateRelationship(docPartUri, TargetMode.Internal, docRelationshipType, <span class="str">"rId1"</span>);</pre>
<pre><span class="lnum">  47:  </span></pre>
<pre><span class="lnum">  48:  </span>                <span class="rem">// Flush the changes then close the package</span></pre>
<pre><span class="lnum">  49:  </span>                pkg.Flush();</pre>
<pre><span class="lnum">  50:  </span>                pkg.Close();</pre>
<pre><span class="lnum">  51:  </span>            }</pre>
<pre><span class="lnum">  52:  </span>            <span class="kwrd">catch</span> (Exception Ex)</pre>
<pre><span class="lnum">  53:  </span>            {</pre>
<pre><span class="lnum">  54:  </span>                EventLog.WriteEntry(<span class="str">"BizTalk 2006 - Build ODF Package"</span>, <span class="str">"Error encountered building the package: "</span> + Ex.Message, EventLogEntryType.Error);</pre>
<pre><span class="lnum">  55:  </span>            }</pre>
<pre><span class="lnum">  56:  </span></pre>
<pre><span class="lnum">  57:  </span>            <span class="kwrd">try</span></pre>
<pre><span class="lnum">  58:  </span>            {</pre>
<pre><span class="lnum">  59:  </span>                <span class="rem">// Rewind the new OOXML stream</span></pre>
<pre><span class="lnum">  60:  </span>                odfStream.Seek(0, System.IO.SeekOrigin.Begin);</pre>
<pre><span class="lnum">  61:  </span>            }</pre>
<pre><span class="lnum">  62:  </span>            <span class="kwrd">catch</span> (Exception Ex)</pre>
<pre><span class="lnum">  63:  </span>            {</pre>
<pre><span class="lnum">  64:  </span>                EventLog.WriteEntry(<span class="str">"BizTalk 2006 - Build ODF Package"</span>, <span class="str">"Error encountered rewinding the stream: "</span> + Ex.Message, EventLogEntryType.Error);</pre>
<pre><span class="lnum">  65:  </span>            }</pre>
<pre><span class="lnum">  66:  </span>            <span class="kwrd">finally</span></pre>
<pre><span class="lnum">  67:  </span>            {</pre>
<pre><span class="lnum">  68:  </span>                <span class="rem">// Add the new OOXML stream into the return message.</span></pre>
<pre><span class="lnum">  69:  </span>                bodyPart.Data = odfStream;</pre>
<pre><span class="lnum">  70:  </span>                pc.ResourceTracker.AddResource(odfStream);</pre>
<pre><span class="lnum">  71:  </span>            }</pre>
<pre><span class="lnum">  72:  </span>        }</pre>
<pre><span class="lnum">  73:  </span>    }</pre>
<pre><span class="lnum">  74:  </span></pre>
<pre><span class="lnum">  75:  </span>    <span class="kwrd">return</span> inmsg;</pre>
<pre><span class="lnum">  76:  </span>}</pre>
</blockquote>
<p>A quick overview of the code is as follows:</p>
<ul>
<li>Line 26: We load a copy of the original message data part stream into an XmlDocument to use as the main document body (the document.xml) when building the package.</li>
<li>Line 31: Create a new OOXML package in a new MemoryStream.</li>
<li>Line 34: Create a URI to the main document body (calling it document.xml).</li>
<li>Line 37: Create the main document body part (docPartUri and docContentType.</li>
<li>Lines 40 &#8211; 43: Save the contents of our BizTalk message to the main document body part (the message we created in the BizTalk map).</li>
<li>Line 46: Create a package relationship for the main document body part.</li>
<li>Line 60 &amp; 69 &#8211; 70: Rewind the the MemoryStream and overwrite the original message with our new OOXML package.</li>
<li>Line 75: We return the message containing the OOXML package.</li>
</ul>
<p>The final message is sent via the FILE adapter and written to the file system. The end result looks like this (click on the image for a larger version):</p>
<p><center><a href="http://www.modhul.com/wp-content/uploads/2008/01/finishedsalessummarydocument.PNG"><img src="http://www.modhul.com/wp-content/uploads/2008/01/finishedsalessummarydocument_small.png" alt="Finished Sales Summary Document - Small" border="0" /></a></center>The complete solution &#8211; containing the pipeline component and a BizTalk proof of concept project &#8211; is <a href="http://www.modhul.com/wp-content/uploads/2008/01/create-ooxml-package.zip" title="Create OOXML Package Solution Sample" target="_blank">available to download</a> and can be found archived in the <a href="http://www.modhul.com/downloads/" title="Downloads Area" target="_blank">downloads area</a> of this blog. Grab a copy, try it out for yourself; comments and suggestions are welcome.</p>
<p><strong>Conclusion</strong></p>
<p>In this post I hope I&#8217;ve shown you the tools necessary to generate Word 2007 documents natively using BizTalk 2006. The example I presented is extremely simple and does not include styles, themes, images, headers and footers, font tables etc. that would exist in a real-life document, but I hope it has presented a starting-point for your own custom development.</p>
<p>These same techniques can also be applied to create Excel spreadsheets or PowerPoint presentations &#8211; in fact, while writing this post I have had a number of ideas for enhancements to the pipeline component  and will endeavour to create a CodePlex project if I can find the time.</p>
<p><strong>Disclaimer</strong></p>
<p>This work is licensed under a <a href="http://creativecommons.org/licenses/by/2.5/" rel="license">Creative Commons Attribution 2.5  License</a> &#8211; you can use commercially and modify as necessary, but you must give the original author credit. Furthermore, sample projects and code are provided “AS IS” with no warranty.Click the image below to view further detail of the licence.</p>
<p><a href="http://creativecommons.org/licenses/by/2.5/" rel="license"><img src="http://creativecommons.org/images/public/somerights20.png" alt="Creative Commons License" style="border-width: 0pt" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.modhul.com/2008/01/17/generating-microsoft-word-documents-natively-using-biztalk-2006/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Message Archiving Receive Pipeline Component</title>
		<link>http://www.modhul.com/2007/04/26/message-archiving-receive-pipeline-component/</link>
		<comments>http://www.modhul.com/2007/04/26/message-archiving-receive-pipeline-component/#comments</comments>
		<pubDate>Thu, 26 Apr 2007 12:24:46 +0000</pubDate>
		<dc:creator>Nick Heppleston</dc:creator>
				<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[Pipeline Components]]></category>

		<guid isPermaLink="false">http://www.modhul.com/2007/04/26/message-archiving-receive-pipeline-component/</guid>
		<description><![CDATA[Update: The Message Archiving Component is now maintained by Atomic-Scope, visit http://www.atomic-scope.com/downloadtrial for more information. Today I&#8217;m releasing a message archive receive pipeline component (BTS06 only) &#8211; I&#8217;ve been meaning to release the code for this component for some time, but never got around to it. The component is designed to be used in the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> The Message Archiving Component is now maintained by Atomic-Scope, visit <a title="Atomic-Scope: Download Message Archiving Component Trial" href="http://www.atomic-scope.com/downloadtrial" target="_blank">http://www.atomic-scope.com/downloadtrial</a> for more information.</p>
<p>Today I&#8217;m releasing a message archive receive pipeline component (BTS06 only) &#8211; I&#8217;ve been meaning to release the code for this component for some time, but never got around to it.</p>
<p>The component is designed to be used in the decode stage of a receive pipeline to archive a message before any BizTalk processing (with the exception of the adapter) is started. An output directory and filename can be specified in the component properties, with the following macros (which will be expanded to their real-world values) available in the filename:</p>
<ul>
<li><strong>%MessageID%</strong> &#8211; Expands to the unique Message Id;</li>
<li><strong>%ReceivedFileName%</strong> &#8211; Expands to the received filename, less the extension;</li>
</ul>
<p>the remainder all expand to their context property values:</p>
<ul>
<li><strong>%InboundTransportLocation%</strong></li>
<li><strong>%InterchangeID%</strong></li>
<li><strong>%ReceivePortID%</strong></li>
<li><strong>%ReceivePortName%</strong></li>
<li><strong>%AuthenticationRequiredOnReceivePort%</strong></li>
<li><strong>%InboundTransportType%</strong></li>
<li><strong>%MessageExchangePattern%</strong></li>
<li><strong>%PortName%</strong></li>
<li><strong>%ReceivePipelineID%</strong></li>
</ul>
<p>For example, specifying an archive filename of:</p>
<blockquote><p><code>%ReceivedFileName%-%MessageID%.xml</code></p></blockquote>
<p>with a file called &#8216;TestArchive.xml&#8217; will produce an output filename of:</p>
<blockquote><p><code>TestArchive-{2AABABE3-4D25-4A5E-A730-E4B9A71B23F7}.xml</code></p></blockquote>
<p>The VS project (including full source-code) can be found in the <a title="Modhul.com - Downloads" href="http://www.modhul.com/downloads/" target="_blank">downloads</a> area under &#8216;Message Archiving Receive Pipeline Component&#8217; (a 14Kb zip file). Details of how to make the compiled binary available in a BizTalk project <a title="Deploying Pipeline Components" href="http://msdn2.microsoft.com/en-us/library/ms946718.aspx" target="_blank">can be found here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.modhul.com/2007/04/26/message-archiving-receive-pipeline-component/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom Disassembler Component &#8211; Remember the Context Properties!</title>
		<link>http://www.modhul.com/2007/03/08/custom-disassembler-component-remember-the-context-properties/</link>
		<comments>http://www.modhul.com/2007/03/08/custom-disassembler-component-remember-the-context-properties/#comments</comments>
		<pubDate>Thu, 08 Mar 2007 16:19:06 +0000</pubDate>
		<dc:creator>Nick Heppleston</dc:creator>
				<category><![CDATA[BizTalk 2004]]></category>
		<category><![CDATA[BizTalk 2006]]></category>
		<category><![CDATA[Pipeline Components]]></category>

		<guid isPermaLink="false">http://www.modhul.com/2007/03/08/custom-disassembler-component-remember-the-context-properties/</guid>
		<description><![CDATA[This is really a post to remind myself not to be quite so stupid in future&#8230;. I&#8217;ve been developing a custom pipeline disassembling component over the last few days to take a single purchase order from a customer and split into multiple orders based on (potentially) multiple delivery addresses. The component worked well through the [...]]]></description>
			<content:encoded><![CDATA[<p>This is really a post to remind myself not to be quite so stupid in future&#8230;.</p>
<p>I&#8217;ve been developing a custom pipeline disassembling component over the last few days to take a single purchase order from a customer and split into multiple orders based on (potentially) multiple delivery addresses. The component worked well through the Pipeline.exe tool but on testing using messaging (Send Port subscribing to messages from a Receive Port configured with the new component) I kept receiving:</p>
<blockquote><p><code>The "FILE" adapter is suspending a message coming from Source URL:"D:\BizTalk Messages\Inbound\Sales Orders\BAA Sales Orders\Order Splitter Test Input\*.xml". Details:"Could not find a matching subscription for the message. ".</code></p></blockquote>
<p>In my wisdom,  I&#8217;d managed to forget that BizTalk is based on a pub/sub model &#8211; if I don&#8217;t copy the input message properties onto the resultant output messages <strong>and</strong> promote the message type, the Send Port might struggle to subscribe&#8230;..</p>
<p>So, note to self &#8211; copy context properties:</p>
<blockquote><p><code>// Iterate through inbound message context properties and add to the new outbound message<br />
for (int i = 0; i &lt; pInMsg.Context.CountProperties; i++)<br />
{<br />
string Name, Namespace;<br />
object PropertyValue = pInMsg.Context.ReadAt(i, out Name, out Namespace);</code><br />
<code><br />
// If the property has been promoted, respect the settings<br />
if (pInMsg.Context.IsPromoted(Name, Namespace))<br />
outMsg.Context.Promote(Name, Namespace, PropertyValue);<br />
else<br />
outMsg.Context.Write(Name, Namespace, PropertyValue);<br />
}</code></p></blockquote>
<p>and promote the message type:</p>
<blockquote><p><code>// Promote the MessageType property to ensure subscription by orchestrations<br />
string systemPropertiesNamespace = "http://schemas.microsoft.com/BizTalk/2003/system-properties";<br />
string messageType = "http://www.covast.com/schemas/EDI/Accelerator2004#EDIFACT_ORDERS_D_98A_DEFAULT_UN";<br />
outMsg.Context.Promote("MessageType", systemPropertiesNamespace, messageType);</code></p></blockquote>
<p>Doh!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.modhul.com/2007/03/08/custom-disassembler-component-remember-the-context-properties/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Add DOCTYPE Declaration Component</title>
		<link>http://www.modhul.com/2006/12/28/add-doctype-declaration-component/</link>
		<comments>http://www.modhul.com/2006/12/28/add-doctype-declaration-component/#comments</comments>
		<pubDate>Thu, 28 Dec 2006 14:15:46 +0000</pubDate>
		<dc:creator>Nick Heppleston</dc:creator>
				<category><![CDATA[B2B]]></category>
		<category><![CDATA[BizTalk 2004]]></category>
		<category><![CDATA[Pipeline Components]]></category>

		<guid isPermaLink="false">http://www.modhul.com/2006/12/28/add-doctype-declaration-component/</guid>
		<description><![CDATA[Our current infrastructure supports over 200 interfaces with external trading partners in the B2B role. Unfortunately, some of the cXML partners cannot handle Xml Namespaces and insist on receiving DOCTYPES. Although DOCTYPE&#8217;s can be added through the BizTalk mapper, we needed a mechanism to remove the Xml Namespace from the resultant message before passing through [...]]]></description>
			<content:encoded><![CDATA[<p>Our current infrastructure supports over 200 interfaces with external trading partners in the B2B role. Unfortunately, some of the cXML partners cannot handle Xml Namespaces and insist on receiving DOCTYPES.</p>
<p>Although DOCTYPE&#8217;s can be added through the BizTalk mapper, we needed a mechanism to remove the Xml Namespace from the resultant message before passing through to a client. As a result, I created the <em>Add Doctype Declaration</em> encoding component (send pipeline) to add DOCTYPE&#8217;s and remove Xml namespaces.</p>
<p style="text-align: center"><img alt="Encode Component on Pipeline" id="image69" src="http://www.modhul.com/wp-content/uploads/2006/12/encode_component_on_pipeline.GIF" /></p>
<p>The component uses an Xml Document object to parse the message and add the DOCTYPE declarations. In addition, the Xml Namespace can be removed if required using the [boolean] &#8216;RemoveNamespace&#8217; property (if this is set to false, the namespace will remain in the final message.</p>
<div style="text-align: center"><img id="image71" alt="Add DOCTYPE Declaration Component Properties" src="http://www.modhul.com/wp-content/uploads/2006/12/component_properties.GIF" /></div>
<p>A project containing source-code and binaries for BizTalk 2004 can be found in the <a title="Downloads Area" target="_blank" href="http://www.modhul.com/downloads/">downloads area</a> of this blog, <a title="Add DOCTYPE Declaration Component" target="_blank" href="http://www.modhul.com/wp-content/uploads/2006/12/send-pipeline-add-doctype-declaration.zip">or via this link</a>.</p>
<p>This really is the first release of the component (think of it as beta) and although it is ready for production, there are a number of enhancements I want to make, including:</p>
<ol>
<li>Produce a version in .Net 2.0 for BizTalk 2006 (our production environment is currently 2004, hence the current code is targeted to .Net 1.1);</li>
<li>For BizTalk 2006, have the component configurable at run-time rather than design-time;</li>
<li>Identify the root element programmatically, rather than through a component property;</li>
<li>Remove DOCTYPE addition from the component and use the mapper to add the declaration;</li>
<li>Create a receive pipeline component to add an Xml Namespace based on a DOCTYPE declaration;</li>
</ol>
<p>I hope this component will be of use, either in your projects or as a starter for enhancements. I will continue to update the code and release enhancements through this blog.</p>
<p>Happy BizTalking!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.modhul.com/2006/12/28/add-doctype-declaration-component/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

