C# 获取biztalk管道组件中的架构信息

C# 获取biztalk管道组件中的架构信息,c#,biztalk,biztalk-2010,C#,Biztalk,Biztalk 2010,早上好, 我感兴趣的是编写一个管道组件,它知道它正在解码的文档模式。我看到有一个函数可以获取组件中的模式信息: IDocumentSpec spec = pContext.GetDocumentSpecByType("name-of-your-schema"); 您可以访问管道中分配的文档架构名称吗?您可以从消息的上下文中获得它,如下所示: private static readonly PropertyBase SchemaStrongNameProperty = new BTS.Schem

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

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

您可以访问管道中分配的文档架构名称吗?

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

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...
}

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

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...
}

看起来正是我要找的。我试试看。谢谢不幸的是,方法pInMsg.Context.Read()返回null。在运行时,SchemaStrongNameProperty.Name.Name=“SchemaStrongName”。命名空间为“”。架构强名称不在消息上下文中。组件将在哪个阶段运行?我计划在反汇编阶段使用它。也许我需要重写它才能在验证阶段工作?实际上,我正试图使用模式中的信息来清理数据。在拆卸后再做同样的工作。我认为验证阶段是最好的。反汇编程序设置了这些信息,所以你必须在那之后再做。看起来正是我要找的。我试试看。谢谢不幸的是,方法pInMsg.Context.Read()返回null。在运行时,SchemaStrongNameProperty.Name.Name=“SchemaStrongName”。命名空间为“”。架构强名称不在消息上下文中。组件将在哪个阶段运行?我计划在反汇编阶段使用它。也许我需要重写它才能在验证阶段工作?实际上,我正试图使用模式中的信息来清理数据。在拆卸后再做同样的工作。我认为验证阶段是最好的。反汇编程序会设置这些信息,因此您必须在这之后进行操作。