Key BizTalk API Objects
All
pipeline components, regardless of what they do, will use the
interfaces described in thefollowing subsections. Likewise, most of the
pipeline component interfaces defined previously accept these
interfaces as arguments. That being said, it is important to understand
these interfaces first before proceeding. The following is based on
material from the BizTalk Server documentation on MSDN.
IPipelineContext
IPipelineContext is the main interface that defines the operations and properties for thepipeline instance. The MSDN documentation from Microsoft provides good examples for how these interfaces are to be used. Tables 1 and 2 show the interface's public properties and methods. The key method here is the GetMessageFactory method. This method will return a message factory for the pipeline that can be used to create new messages using the CreateMessage method.
The GetMessageFactory method is the main way to create new messages from withina pipeline component. Also note that you will need to call IPipelineContext. GetMessageFactory.CreateMessagePart to create the message part for the message. A message is simply a construct that contains zero to many message
parts. Once you create the message part, you can assign it to the IBaseMessage object through the AddPart method.
Table 1. PipelineContext Public Properties
PropertyDescription | |
---|
ComponentIndex | Gets the index of the current component in the stage. |
PipelineID | Gets the ID of the pipeline with which this pipeline context associates. |
PipelineName | Gets the name of the pipeline. |
ResourceTracker | Gets the IResourceTracker object associated with the pipeline context. This object can be used to track and dispose non-CLR resources. |
StageID | Gets the ID of the current stage in the pipeline. |
Stagendex | Gets the index of the pipeline stage where the current component is located. |
Table 2 . PipelineContext Public Methods
Method | Description |
---|
GetDocumentSpecByName | Gets an IDocumentSpec object for the specified document name |
GetDocumentSpecByType | Gets an IDocumentSpec object for the specified document type |
GetGroupSigningCertificate | Gets the signing certificate for the group |
GetMessageFactory | Get access to the helper interface to work with BizTalk Server message objects |
IBaseMessage
IBaseMessage is the base interface that defines a BizTalk Server message. Tables 3 and Table 4 show the public properties and methods. The MSDN documentation from Microsoft provides good examples for how these interfaces are to be used. Note that messages, created using the IPipelineContext.GetMessageFactory.CreateMessage method, will implement this interface. This will still need an IBaseMessagePart to be assigned through the AddPart method for any data to be included with the message.
Table 3. IBaseMessage Public Properties
Property | Description |
---|
BodyPart | Gets the body part, or main part, of the message |
BodyPartName | Gets the name of the body part, or main part, of the message |
Context | Gets or sets the message context |
IsMutable | Gets a value indicating whether the message can be changed by components during processing |
MessageID | Gets the unique message ID for the message |
PartCount | Gets the total number of parts in the message |
Table 4. IBaseMessage Public Methods
Method | Description |
---|
AddPart | Adds a part to the message. |
GetErrorInfo | Gets the exception that caused the error. |
GetPart | Accesses the message part. This is indexed by PartName. |
GetPartByIndex | Retrieves a part and its name by supplying the part index. |
GetSize | Gets the size of the message. |
RemovePart | Removes a part from the message. |
SetErrorInfo | Sets the error information. |
IBaseMessagePart
IBaseMessagePart is the interface that defines a BizTalk message part. Table 5 and Table 6 show its public properties and methods. The message part is assigned to an IBaseMessage through the AddPart method. Note the Data property. The MSDN documentation
from Microsoft provides good examples for how th. This is the property
used to assign a value to the message part. The Data property accepts
and returns only streams. This is incredibly useful, as it allows any
stream to be assigned to the message part. This includes XMLReader
streams, MemoryStreams, and raw BinaryStreams.
Another rarely used item is the PartProperties property. This is essentially a property bag that can be used to store information and metadata about the part. In reality the PartID, Charset, and ContentType are actually contained in the PartProperties IBasePropertyBag object.
Table 5. IBaseMessagePart Public Properties
Property | Description |
---|
Charset | Gets or sets the character set property for the part |
ContentType | Gets or sets the content type property for the part |
Data | Gets or sets the part data |
PartID | Gets the part with a unique ID |
PartProperties | Gets or sets one or more properties that describe the part data or contain custom information about the part |
Table 6. IBaseMessagePart Public Properties
Method | Description |
---|
GetOriginalDataStream | Retrieves the original uncloned version of the part data stream |
GetSize | Retrieves the size of the part |
IBaseMessageContext
IBaseMessageContext is the interface used to interact with and manipulate the object context accessible through the IBaseMessage.Context property. Table 7 and Table 8 show the public properties and methods. The MSDN documentation from Microsoft provides good examples for how these interfaces are to be used. The main items of interest here are the Promote, Read, and Write
methods. Properties that exist in the context can never have a Null
value. A Null value means that the property does not exist. For example:
Table 7. IBaseMessageContext Public Property
Property | Description |
---|
CountProperties | Gets the number of properties in the message context |
Table 8. IBaseMessageContext Public Methods
Method | Description |
---|
AddPredicate | Adds a message predicate to the message |
GetPropertyType | Gets the type of the property |
IsMutable | Indicates whether the message context can be changed by components during processing |
IsPromoted | Enables the component to determine whether a property has already been promoted in the message context |
Promote | Promotes a property into the message context |
Read | Gets a property value from the message context by the name-namespace pair |
ReadAt | Gets a property from the message context by index |
Write | Writes a property into the message context |
PipelineUtil
PipelineUtil is a helper class that exposes the three methods shown in Table 9. These methods are invaluable when you need to create a new message. The MSDN documentation from Microsoft provides good examples for how these interfaces are to be used.
Table 9. PipelineUtil PublicMethods
Method | Description |
---|
CloneMessageContext | Creates
a clone of the message context for a given message. This is useful for
copying the message context of one message to another. |
CopyPropertyBag | Creates a clone of the property bag for a given message. This is useful for copying the property bag of one message to another. |
ValidatePropertyValue | Checks that the object is a valid property value. |
This
class is unsupported and is part of the BizTalk product infrastructure.
If you run into trouble using it, Microsoft Product Support may not
support you. However, it is common knowledge that it exists and makes
pipeline component development much easier. |