As you most likely are aware, when a document is received by a BizTalk Server adapter, the adapter creates a BizTalk message for the document. The BizTalk message contains the document that was received as well as the message context. The message context is a container for various properties that are used by BizTalk Server when processing the document. Each property in the Message Context is composed of three things, a name, a namespace, and a value.
Message context properties are added to the message context throughout the lifetime of the message as it passes through the BizTalk Server. These properties:
There are mainly two benefits of this context:
However, there are several out-of-the-box BizTalk Server context properties that are not exposed (promoted) and by that, they are not available for routing in BizTalk Server. This behavior is common to all versions of BizTalk Server, not to a specific one. You can know more about all out-of-the-box BizTalk Server context properties on this extended whitepaper:
Nevertheless, BizTalk Server allows you to extend these out-of-the-box capabilities by adding new custom property schemas to your solutions. Once after deployment, these custom context properties can be used in all components, inside Orchestrations, pipelines, or ports.
One such property is the ReceiveLocationName property. While ReceiveLocationName is available on the http://schemas.microsoft.com/BizTalk/2003/system-properties namespace and we can see it in the Context of the message inside the BizTalk Server:
The ReceiveLocationName property is not promoted in the BTS namespace, only the ReceivePortName property is available. Therefore, we cannot access it inside an Orchestration or add a filter in a send port using the BTS.ReceiveLocationName syntax.
Nonetheless, we can access this information for example using a custom pipeline component inside a receive pipeline by using this command:
string receiveLocationName =
To bypass this behaviour, and as I mentioned above, BizTalk Server allows you to create custom property schemas and extend the out-of-the-box promotions with more fields. So for us to easily promote the ReceiveLocationName property we need to create a custom Property Schema.
As far as BizTalk Server message properties go, they can be assigned Property Schema Base types of:
Taking this information into account, what we now need to do is:
|Property Name||Date Type||Property Schema Base|
Note: A MessageContextPropertyBase property means that the XPath may or may not exist.
Now that we have the schema, we just need to create a Custom Pipeline component and a custom receive pipeline to promote this property to the context of the message
To actually promote the properties to the context of the message, we need to create a custom pipeline component and a custom receive pipeline to do the trick.
The custom pipeline is quite simple, we just need two lines of code:
string rlocationname = (string)pInMsg.Context.Read("ReceiveLocationName",
The above line reads the receive location name that was executed in runtime. And this line below will promote the value to the field we create earlier:
pInMsg.Context.Promote("ReceiveLocationName", "<target-namespace-schema-created-above>", rlocationname);
On the pipeline, we just need to drag the component we create for example to the Decode component:
You can find a sample of the custom component and pipeline here: