<?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; Codeplex</title>
	<atom:link href="http://www.modhul.com/category/codeplex/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>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>
	</channel>
</rss>

