在biztalk管道组件中获取架构信息

本文关键字:信息 获取 biztalk 管道 组件 | 更新日期: 2023-09-27 17:58:14

早上好,我感兴趣的是编写一个知道正在解码的文档模式的管道组件。我看到有一个函数可以获取组件中的模式信息:

IDocumentSpec spec = pContext.GetDocumentSpecByType("name-of-your-schema");

你能访问管道中分配的文档架构名称吗?

在biztalk管道组件中获取架构信息

您可以从消息的上下文中获得它,如下所示:

private static readonly PropertyBase SchemaStrongNameProperty = new BTS.SchemaStrongName();
private static readonly PropertyBase MessageTypeProperty = new BTS.MessageType();
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
{
    // Get by schema strong name (.NET type)
    string schemaStrongName = pInMsg.Context.Read(SchemaStrongNameProperty.Name.Name, SchemaStrongNameProperty.Name.Namespace) as string;
    pContext.GetDocumentSpecByName(schemaStrongName);
    // Get by message type (XML NS#Root Node)
    string messageType = pInMsg.Context.Read(MessageTypeProperty.Name.Name, MessageTypeProperty.Name.Namespace) as string;
    pContext.GetDocumentSpecByType(messageType);
    // Rest of your pipeline component's code...
}