I’ve been working on a BizTalk solution which includes a scenario in which I am receiving envelope messages that are to be debatched in a receive pipeline using an XML Disassembler pipeline component, correlating the debatched messages which will be of different message types to relevant orchestrations where they will once again be batched up into an envelope message using an XML Assembler based send pipeline before being sent out.
This sounds like BizTalk bread and butter, but the catch was that the messages that were being assembled were of different message types and that they had been previously debatched using an XML Disassembler. When a message is debatched by the XML Disassembler a property called DocumentSpecName MIGHT be written to the context of the message (I’ve highlighted the word might because I have not yet figured out what the exact conditions are that cause this property to be set, it did not happen when I tried to replicate the problem in a simpler solution but definitely still happens in my original solution). If the first message to be batched by the XML Assembler based send pipeline contains a DocumentSpecName context property, then the pipeline will choke if any of the subsequent messages are of a different message type and you will get the following error (which is rather misleading as it leads you to think that the pipeline has been misconfigured or that the schema has not been deployed properly) – There was a failure executing pipeline “PipelineName”. Error details: “The document type “xxxx#yyyyy” does not match any of the given schemas.
To get around this issue, you should remove the DocumentSpecName context property from any messages before they are batched up in the send pipeline. You can do this in a pipeline component in the receive pipeline that gets run in any stage after the disassemble stage. To remove the property you will need to add the below line to the execute method in your pipeline component (I’d encourage you to write pipeline components to be dynamic rather than hardcoding which properties to promote/remove so please only treat this as an example).
Of course if you are not debatching messages on the way in, or if all the debatched messages are of the same type then you will not encounter this problem.
Once again, I will reiterate that I don’t yet know what the exact conditions are for the XML Disassembler to set the DocumentSpecName property onto a message, but if you run into the same error message and you are sure that the schema mentioned in the error message is properly deployed, then do check to see if the DocumentSpecName property exists on your message, and if so remove it. If at any point I do find the exact conditions I will update this blog post.