Tag Archives: Property Promotion

Very Strange behavior of XML Disassembler- Property Promotion not happening properly

While working on a pipeline component I encountered a very strange behavior of XML disassembler. I had few promoted properties which I was trying to access in a pipeline component in Validate stage after the execution of XML Disassembler. As we all know that the Pipelines are executed in sequential manner and the output of one pipeline component is used as input to the next one in the sequence(except in Disassemble stage). ( Read more- Understanding Pipeline Execution). So, ideally after execution of XML Disassembler, Promoted Properties should be accessible in later stages. But shockingly there value was NULL. Now let’s have a look into my sample BizTalk application for better understanding. I have a simple schema in which both the properties are promoted- Source&PropertySchema Emp & Property Schema Image I created a simple pipeline component where I tried to read values of ID and Name from message context using below code and later promoted “ReceiveFileName” FetchingPromotedProps Fetching Promoted Properties in Pipeline Component Image Created a simple Custom Receive Pipeline with XML Disassembler and later used my pipeline component in Validate Stage. ReceivePipeline Receive Pipeline Image But strangely when I tried to fetch the promoted properties found out that it’s returning NULL as shown below. PromotedPropsAsNullAfterCommentingTheReadOperation Promoted Properties as NULL in Pipeline component Image Cause:- After some research got to know that it’s a known behavior. Basically, the XmlDisassembler does not read through the incoming message immediately.  It waits until some later component or the MessageBox reads it.  This is done for various performance reasons like memory consumption, etc. So, since my custom pipeline component is next in line, when it gets the Message, data has not yet been read by the XmlDisassembler even though it passed that Stage in the Pipeline, so it hasn’t had a chance to Read and Promote any Context Properties.  This is by design, and what you are seeing is a known side-effect. Its accomplished by wrapping the data in a custom Stream class.  That is why it only gets read and processed when some other component reads it. Solution/Workaround:- The easiest option would be to just do you work with the Properties in an Orchestration. If you absolutely have to use a Pipeline Component, then you will have to somehow force a Read by the XmlDisassembler. For example in our pipeline component we have read the values using below code and forced a Read/Promote by the XmlDisassembler. //Reading message data using XML Document. System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.Load(originalStream); Using XMLDoc can have performance implication as the complete message will be loaded in memory, so you can use the below code as well. //Reading message data using Stream, this will not have any performance implication. System.IO.MemoryStream ms = new MemoryStream(); originalStream.CopyTo(ms); ms.Position = 0; inmsg.BodyPart.Data = ms; As shown in below image.  PromotedPropsAfterReadingTheValueUsingStream  Promoted Properties containing Value After performing Forced Read by XML Disassembler Image   Check the discussion over the same issue- XML Diassembler component is not doing property promotion   Hope it helps.   Download the sample application from here. Word version of this blog is here.  

Contact Me:- 

@Gmail@Facebook , @Twitter, @LinkedIn @MSDNTechnet, @My Personal Blog 

Advertisement

Implementing Correlation (Property Promotion) without any Common Element

I recently encountered a scenario where I had to implement correlation without any common element between the outgoing and incoming messages. Generally we implement correlation by Initializing and following correlation on the same element.

Let’s come to our sample for better understanding.

We have two schemas “Candidate” with fields as CandidateID, Name City and Status and “Employee” schema with fields as EmployeeID, Name, ReportingCity and ReportingManager.

We need to initialize correlation for CandidateID and follow correlation on EmployeeID. But as these are two different elements so they can’t become one CorrelationType. However they hold the same value.

Candidate, Employee & PropertySchema

 Candidate, Employee and Property Schema Image

Solution: – I created a PropertySchema with one element as “UniqueID” and promoted CandidateID and EmployeeID against it.

How to achieve it:-

  • Create on property schema with one element as “UniqueID”
  • In Candidate schema, Right click on CandidateID-> show promotion ->Property Fields -> Click on top right corner a folder like icon (Add new Property Schema) and select the property schema created in first step.
  • Now click on the CandidateID and “Add”. This will add the property for CandidateID field as shown below.

PropertyPromotion

Property Promotion Image

  • Perform the same steps to promote EmployeeID field as well present in Employee Schema.

Let’s have a look into the final schemas. If you notice in the Properties section you will find PropertyName = “UniqueID”. It means EmployeeID or CandidateID will be promoted against UniqueID field present in Property Schema.

Employee Schema

EmployeeSchema

Employee Schema Image

Candidate Schema

CandidateSchema

Candidate Schema Image

Let’s create our Orchestration to meet our requirement. Only important thing to notice is how the correlation set is created and later used.

CorrelationSet

Creating Correlation Set Image

Later in Orchestration I have initialized Correlation while sending the Candidate information for approval and followed the same while receiving the Employee Info (Approved Candidates)

Orchestration

 Orchestration Image

Some interesting things:-

Created a test file with CandidateID = 1 and processed the same.

PromotedPropertiesOfCandidateSchema

Promoted Properties of Candidate Schema Image

Subscription Filter on Correlated Receive shape:-

https://CorrelationWithoutCommonElement.PropertySchema.UniqueID == 1  And

http://schemas.microsoft.com/BizTalk/2003/system-properties.ReceivePortID == {6D17881D-4468-4EFD-A4EB-A05327E8DAE7}  And

http://schemas.microsoft.com/BizTalk/2003/system-properties.MessageType == http://CorrelationWithoutCommonElement.Employee#Employee

Correlated Receive shape has an instance subscription i.e. an instance of Orchestration is waiting for a particular type of message.

The main motive of this sample is to demonstrate how to do property promotion if you don’t have any common element.

Hope it helps.

Download the sample application from here. Word version of this blog is here.

 

Contact Me:- 

@Gmail@Facebook , @Twitter, @LinkedIn @MSDNTechnet, @My Personal Blog