Stephen W. Thomas BizTalk Blog

100% Pure BizTalk
posts - 132, comments - 146, trackbacks - 438

My Links

News

Subscribe to my blog via:


Add to Google

Visit my website at:
www.BizTalkGurus.com

Archives

BizTalk 2004 Samples

BizTalk 2006 Samples

BizTalk Videos

BizTalk White Papers

BizTalkBlogs.com

Great BizTalk Blogs

Other Links

Untyped Send and Receive Ports in BizTalk 2004 Orchestrations

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.

Print | posted on Tuesday, August 10, 2004 7:20 PM |

Feedback

Gravatar

# re: Untyped Send and Receive Ports in BizTalk 2004 Orchestrations

Stephen,

This post is very interesting and with a particular business process I am working on, would save me creating several orchestrations of a simmilar flavour. However, I do not seem to be able to setup a filter expression that will match for the outgoing message based on the context properties attched to the message? I have a simple pipeline component that logs the context properties from messages that pass through it and I can see all the properties I need and their values are set correctly however, the filter expression on my send port does not match them and I get the familiar routing failure. Has it been your experience that you cannot route based on messages of type XmlDocument? Is there something I am missing?

Thanking you in advance for your time

Mike
1/29/2005 8:19 AM | Mike P
Gravatar

# re: Untyped Send and Receive Ports in BizTalk 2004 Orchestrations

Mike,

Yes, you are correct that Untyped messages sent out of the Orchestration can not be routed to Send Port very easily. This is because all the properties, except one or two, are not promoted. I think you can force these values to be promoted by Initializing a Correlation Set on the Send Shape.

Charles Young talks about it here: http://geekswithblogs.net/cyoung/articles/17364.aspx

I have been meaning to try this, but I have not gotten around to it yet.

We are using Untyped messages on my current project. It allows us to have only 3 Orchestration rather then 50. I real time saver but we have to store a lot of info outside the Orchestration (like map names).

Stephen
1/29/2005 10:50 AM | Stephen W. Thomas
Gravatar

# re: Untyped Send and Receive Ports in BizTalk 2004 Orchestrations

Does anyone have an example to do correlation on a untyped xml? so far I have not been able to get correlation working on a untyped xml message.
4/29/2005 4:10 PM | Mike
Gravatar

# re: Untyped Send and Receive Ports in BizTalk 2004 Orchestrations

Hello.

I think they key is to use Message Context Properties for any custom properties that you want to correlate on. I have not tried it, but I do not see why it would not work.

Let me know if you have additional questions.

Stephen W. Thomas
5/4/2005 11:27 PM | Stephen W. Thomas
Gravatar

# re: Untyped Send and Receive Ports in BizTalk 2004 Orchestrations

Hi,

With the same scenario I would like to add map(s) in Send pipeline. Is this possible.

Thanks,
Iq
5/14/2005 2:14 PM | Iq
Gravatar

# re: Untyped Send and Receive Ports in BizTalk 2004 Orchestrations

Hi,

With the same scenario I would like to add map(s) in SendPort. Is this possible?

Thanks,
Iq
5/14/2005 2:16 PM | Iq
Gravatar

# re: Untyped Send and Receive Ports in BizTalk 2004 Orchestrations

Hello.

I think you can do it if you create a correlation set on the Send with the BTS.MessageType property. I have not tried it, but I think that should work.

Stephen W. Thomas
5/17/2005 9:23 PM | Stephen W. Thomas
Gravatar

# re: Untyped Send and Receive Ports in BizTalk 2004 Orchestrations

Have you done this with hl7 mllp send/receive ports? The message type for the send receive shapes are multipart consisting of a XMLDocument type header, XmlDocument type Body and string type Zsegment. The XmlDocument body is what makes the send/receive ports untyped when dealing with hl7. hl7 comes in as a string delimited with | ^ and & characters. The string then gets serialized to xml based on a schema which is happening correctly. The problem occures when send the message through the send port, Biztalk suspends the message with an error "Body schema missing". I think this is because it doesn't know how to deserialize from the XmlDocument type to an hl7 stream. This would likely work if the send port wasn't untyped. Any ideas on how to get it to work with an untyped send port?
9/1/2005 3:24 PM | Jeremy

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 4 and 7 and type the answer here:

Powered by: