Martijn's blog - E-Commerce, EAI, BizTalk and .NET


Retrieving the matching schema for an inbound message

Ever wanted to know which schema matches your inbound message from within a pipeline component? Here's how:

Reference Microsoft.BizTalk.Streaming,

Use the following code within your pipeline component:

Stream orgStream =

MarkableForwardOnlyEventingReadStream helperStream =
   new MarkableForwardOnlyEventingReadStream(orgStream);

IDocumentSpec docSpec = null;

try {
  docSpec =
catch(Exception e)

if(docSpec != null)
  XmlSchemaCollection schemaCollection =
    // use the schema collection
     "No schemas found matching our inbound message");

Now you have the schema collection which matches your document (this code is minimal, real exception handling should be added ofcourse.


Utils.GetDocType does nothing more then read the stream using a XmlTextReader and combine any found namespace with the root element name. If you have DOCTYPE declarations, you could implement this yourself to avoid having to put your DTDs in %windir%\system32.

The MarkableForwardOnlyEventingReadStream class helps in easily resetting the position back to where the stream was once the Utils.GetDocType is done.

Hope you find this useful!


  • sometimes you can go to earn the mabinogi gold for your own life and you can also get a lot of happiness in the game if you play the game well. you can brush the cheap mabinogi to upgrade and then you are very strong. You think that you want to play the game well and then you can get the mabinogi money for your own. you can go to buy mabinogi gold alone and you can give some for your friends; it can make you very happy I think. As long as you play the game you can get the mabinogi online gold as the rewards in this game.

    By Anonymous Anonymous, at 1:27 AM  

Post a Comment

Links to this post:

Create a Link

<< Home