Scott posted a message back in June about untyped receive ports inside on Orchestration. Untyped Messages means you receive or send a message as System.Xml.XmlDocument rather then a specific schema type. This is an incredibly powerful feature in BizTalk 2004!

Business Case:

Lets say you want to have one Orchestration (i.e. a single business process) to process many different types of messages all in the same way. Additionally, say you want to change some values in your message and send all of your messages out through the same Send Shape (i.e. send messages as Xml.XmlDocument).

Lets say you can have a Book Review and a Movie Review. You want them both to be processed in the same way though the same Orchestration, maybe send information to an outside web service or something like that. Additionally, you have to extract out promoted properties of the message inside the Orchestration and make decisions inside the Orchestration on them. This can not be done with Xml.XmlDocument since the Orchestration will not allow you to access them (they are in the message context, just you can not get at them).

Confused? How about we look at a sample.

DOWNLOAD: Get the sample here!

Set-up is easy, just unzip the SampleProperties folder and put it on your C: drive. Then, build and deploy the SampleProperties project. I use early binding so the send and receive ports will be created for you.

To run the sample, drop the 4 Start….xml message into c:\SampleProperties\In. You will get 4 messages in your Out folder. Plus, 4 events will be written to your event log. Do not forget to look inside the expressions shapes inside the Orchestration for comments. If all else fails, read the ReadMe.txt file.

Key Take Home Points:

– Common properties must be promoted in all of the different schemas (look at the promotions in both BookReview.xsd and MovieReview.xsd)

– Messages for type XmlDocument can be cast into different types

– Typed messages can be cast back into XmlDocument

– Blank Schema can be created and properties changed (look at Movie Review branch)

– This is using Property Promotion and Demotion in the XML Pipelines

– As a test, set the Send Pipeline to Pass Through and see the difference in the Movie Review output data.

– This will also work for distinguished fields

CRITICAL: This process is kind of risky since you can pass in any XML Document. You can end up with an invalid cast exception or XPath query not valid.

What is this Movie Review Branch inside the Orchestration really doing?

  1. Taking in a message of type Xml.XmlDocument
  2. Casts the In message to CastMovieIn (strongly typed to a schema)
  3. Sets Orchestration variables based on promoted properties inside the MovieReview schema
  4. Creates a new XML Document (CastMovieOut) and loads a blank schema for that type
  5. Changes values inside CastMovieOut
  6. Creates a new message, Out, as XmlDocument
  7. Casts the CastMoveOut to Out

Take Away: Using XmlDocument can greatly increase the flexibility inside your Orchestration.