Table of Contents IntroductionProperty Demotion Example CasesWalk Through stepsIn what cases Property Demotion happens?See Also
All of us are well aware of Property Promotion, but property demotion is less known topic.
MSDN defines property demotion at http://msdn.microsoft.com/en-us/library/aa547894.aspx as below
“You can use property demotion to copy a property value from the message context into the message content or to its header or trailer”
Property Demotion happens in send pipelines (other than passthru transmit) assembler stage. Property demotion only happens for the applicable properties in the message context. I will explain them later what they are.
So when a BizTalk send port receives message from message box, it gets message as IBaseMessage with message content(message parts) + message context.
If it is a send pipeline other than pass thru, then
it will receive message as IBaseMessage with message content(message parts) + message context. And few applicable properties are demoted in assembler and after processing all stages this IBaseMessage is sent to send adapter,
and the adapter leaves the message context to garbage collection and sends message content(message parts) to destination.
If it is a pass thru transmit pipeline, it still receives message as IBaseMessage with message content(message parts) + message context and since there are no components to process, this IBaseMessage
is sent to send adapter, and the adapter leaves the message context to garbage collection and sends message content(message parts) to destination.
We use property demotion in cases for example
You receive an envelop message with some fields in header. You want to debatch it and for every out going message you want to send it with a custom envelop which will have some of the field values extracted from header of the incoming
In this case:
You may get confused for step 2, I will elaborate it later.
That’s it, when you drop the incoming file, properties of the incoming envelope header fields will be promoted and while sending out the debatched message, those properties are demoted from the context into the header section of
every outgoing envelop message.
Similarly we use property demotion for another case, where we want to use some field values from the header part of the incoming file to the body part fields of every out going message (in first example, we demoted into header section fields of outgoing
message, but in this case we want to demote in to body part fields).
As I said I will dig in to show how property demotion happens for applicable fields with 2nd example case.
we shall create 2 xml schemas:
Create EmployeeInfo schema like below.
Create Envelop Schema Employees like below.
Now import Employee schema into this envelop schema.
Now set the data structure type of the record EmployeeInfo to ns0:EmployeeInfo like below.
Now the employees envelop schema should look like below.
If you notice I have created the names of fields in header and in body parts with similar names “companyName” and “city” as it is. I set it so just for simplicity, not mandatory, you can set any name.
Now our agenda is to populate data from header part to some fields in individual outgoing message using property demotion. For this purpose whatever the fields you want to populate values in outgoing message, we have to keep those fields empty in the incoming
file. Then the outgoing file should come with populated values in them using property demotion.
In this case, I want to populate CompanyName, City from Header part and File path location from the system promoted property
So our input file contains empty nodes like below.
So when this envelope message comes into BizTalk, we have to debatch it with following conditions:
Now that you have imported the schema into envelope schema , select the Root node in envelop schema and set the BodyXpath property to the node “Body”.
Now we will dive into property promotion and demotion. We need to promote the fields now. Because they should be available in the context so as to demote them and write them to outgoing message in send port.
In Employees envelop schema, promote the two properties “CompanyName” and “City”. You may use quick promoted option to create the property schema auto created.
Now the following step is important, we will promote elements from EmployeeInfo schema into already created fields in property schema.
So open EmployeeInfo schema, right click on CompanyName element –> Promote –> and select show promotions options. In the opened window, click on PropertyFields tab.
Now click on folder open icon and import/refer following two things:
Refer already created property schema.
Refer system global property schema “BTS.bts_system_properties” (you have to select from references section in the window) and click OK.
Now from the window add the fields “company”, “city” and “FileReceivedLocation” to promote them. Now here make sure you set the right node for the Node Path section. By default it selects first element, change as per need.
For FileReceivedLocation property, set inboutTransportLocation property.
At the end it should look like below.
Keep following things in mind if you follow the above example.
I noticed that if multiple schemas share the same fields in property schema, property demotion attempt happens.
In our case:
So, for one field in property schemas(be it custom or BizTalk Global property schema) if there is a match from multiple schemas, then in such cases property demotion attempt happens.
There may be other cases too depending on requirement,
Your ideas, inputs are welcome
Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk
Server Resources on the TechNet Wiki.