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

时间:2013-02-06 17:19:28

标签: c# biztalk biztalk-2010

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

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

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

1 个答案:

答案 0 :(得分:5)

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

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