Sometimes the property demotion rules are very difficult to apply in the Xml Assembler Pipeline. There are some limitations:

   • The Biztalk context dependency forces that data must be in message context when the demote occurs;
   • Orchestrations must promote all the data to be demoted, so there is a dependency orchestration -> pipeline;
   • The data to demote cannot be accessed by the orchestration;
   • The data to be demoted can only be calculated in the pipeline context;
   • Little control of the process; 

The problem can be solved creating a custom pipeline component. There are two interfaces that can help our job, IDocumentSpec and IPropertyAnnotation.

The IDocumentSpec (http://msdn2.microsoft.com/en-us/library/microsoft.biztalk.component.interop.idocumentspec.aspx) can be obtained by IPipelineContext interface methods GetDocumentSpecByName and GetDocumentSpecByType. It is used to get document or envelope schema property and distinguished fields (by IPropertyAnnotation).

The IPropertyAnnotation interface allow us to access data from property and distinguished fields.
It can be obtained using IDocumentSpec methods GetPropertyAnnotationEnumerator (property fields) or GetDistinguishedPropertyAnnotationEnumerator (distinguished fields).
IPropertyAnnotation has three main properties: Name, Namespace and Xpath:
• Name is the name of the property schema;
• Namespace is the property schema namespace;
• Xpath is the Xpath query to access the schema element;

With these properties we can set any data dynamically in messages. We can use the name and namespace to access context data, query a database or other repository and use Xpath to set the data.

Example

IDocumentSpec documentSpec = pipelineContext.GetDocumentSpecByName(MESSAGE_SCHEMA_NAME or MESSAGE_ENVELOPE);
                                            
IEnumerator annotations = documentSpec.GetPropertyAnnotationEnumerator();

while (annotations.MoveNext()) {
    IPropertyAnnotation annotation = (IPropertyAnnotation)annotations.Current;
    // Use annotation.Name or Namespace to get the data to demote in message
    // Make manual demoting using annotation.Xpath.
}
     
       
Usage scenario

1. Use IDocumentSpec to retrieve all message schema or envelope annotations;
2. Use annotation Name and Namespace properties  to get data to demote (from message context, database or other source);
3. Use  annotation Xpath property to make message manual demotion;

LEAVE A REPLY

Please enter your comment!
Please enter your name here