The release of BizTalk 2006 has brought a lot of love to the messaging engine in terms of handling failures. Probably the biggest change was messaging errors like “no subscription” are now resumable. However, there are other changes such as being able to subscribe to failed messages using the ErrorReport context properties and enabling routing for failed messages on a receive or send port.
Another change was added in the Xml and Flat File disassemblers – that of recoverable interchange processing. When a disassemble is breaking apart a composite message either in the form of a flat file or an envelope schema what happens if something is wrong about one of the child messages? In BizTalk 2004 the entire batch would fail. In BizTalk 2006 this is still the default behaviour; however, you can now set RecoverableInterchange to true on the disassembler which will cause all successful messages to be processed and only the incorrect ones to fail.
This seems like a great idea but in this article I want to look at some of the subtleties in the XmlDisassembler that make this technology less useful than may first appear.
First, here is the setup. I have two schemas: an envelope that is simply a container for repeated records; a person schema with child elements firstName and lastName as part of a sequence group.
This is the person schema
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
xmlns="http://dotnetconslt.co.uk/schema/person"
targetNamespace=http://dotnetconslt.co.uk/schema/person
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="firstName" type="xs:string" />
<xs:element name="lastName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
And here is the envelope
<xs:schema xmlns:ns0="http://dotnetconslt.co.uk/schema/person"
xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
xmlns="http://dotnetconsult.co.uk/schema/envelope"
targetNamespace="http://dotnetconsult.co.uk/schema/envelope"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import schemaLocation=".\person.xsd"
namespace="http://dotnetconslt.co.uk/schema/person" />
<xs:annotation>
<xs:appinfo>
<b:schemaInfo is_envelope="yes"
xmlns:b=http://schemas.microsoft.com/BizTalk/2003 />
<b:references>
<b:reference
targetNamespace="http://dotnetconslt.co.uk/schema/person" />
</b:references>
</xs:appinfo>
</xs:annotation>
<xs:element name="envelope">
<xs:annotation>
<xs:appinfo>
<b:recordInfo body_xpath="/*[local-name()='envelope' and
namespace-uri()='http://dotnetconsult.co.uk/schema/envelope']" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1"
maxOccurs="unbounded"
ref="ns0:person" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Notice the emboldened pieces that the XmlDisassembler uses to break apart the envelope.
Now, I deploy these two schemas into Biztalk, and then create a Receive Port with a Receive Location using the XmlReceive pipeline. I make sure that error reporting is turned on.

Next I create two send ports: one with a filter set to the BTS.ReceivePortName of the receive port; one using a filter set for error reporting like this

So with the infrastructure in place we can try submitting a message. Let’s start with one that works just to ensure that the envelope is working correctly. Here is the good message:
<ns0:envelope xmlns:ns0="http://dotnetconsult.co.uk/schema/envelope">
<ns1:person xmlns:ns1="http://dotnetconslt.co.uk/schema/person">
<firstName>Rich</firstName>
<lastName>Blewett</lastName>
</ns1:person>
<ns1:person xmlns:ns1="http://dotnetconslt.co.uk/schema/person">
<firstName>Niels</firstName>
<lastName>Bergland</lastName>
</ns1:person>
<ns1:person xmlns:ns1="http://dotnetconslt.co.uk/schema/person">
<firstName>Jason</firstName>
<lastName>Whittington</lastName>
</ns1:person>
</ns0:envelope>
And as expected, dropping this into the receive folder results in three messages in the non-error send folder.
Now let’s use this message
<ns0:envelope xmlns:ns0="http://dotnetconsult.co.uk/schema/envelope">
<ns1:person xmlns:ns1="http://dotnetconslt.co.uk/schema/person">
<firstName>Rich</firstName>
<lastName>Blewett</lastName>
</ns1:person>
<ns1:personbad xmlns:ns1="http://dotnetconslt.co.uk/schema/person">
<firstName>Niels</firstName>
<lastName>Bergland</lastName>