BizTalk 2010映射目标消息显示所有节点

时间:2013-07-12 13:09:16

标签: biztalk biztalk-2010 biztalk-mapper

我有一个源模式,其元素少于目标模式。当我运行地图时,只显示目标模式中的映射元素。我希望目标模式中的所有元素都显示出来,即使它们是空的。怎么做?

2 个答案:

答案 0 :(得分:1)

设置"默认值"输出模式。这将创建空节点。

答案 1 :(得分:0)

最方便的方法是使用Inline C#Scripting functoid。

脚本functoid:

public string GetEmptyString()
{
    return System.String.Empty;
}

您可以将此functoid链接到您希望看到空节点的所有输出节点。

示例:

输入架构:

<xs:schema xmlns="http://person" targetNamespace="http://person" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Person">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Name" type="xs:string" />
                <xs:element name="Surname" type="xs:string" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

输出架构:

<xs:schema xmlns="http://employee" 
           targetNamespace="http://employee" 
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Employee">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="FirstName" type="xs:string" />
        <xs:element name="MidName" type="xs:string" />
        <xs:element name="LastName" type="xs:string" />
        <xs:element name="Age" type="xs:string" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

输入讯息:

<ns0:Person xmlns:ns0="http://person">
  <Name>John</Name>
  <Surname>Snow</Surname>
</ns0:Person>

预期输出消息:

<ns0:Employee xmlns:ns0="http://employee">
  <FirstName>John</FirstName> 
  <MidName /> 
  <LastName>Snow</LastName> 
  <Age /> 
</ns0:Employee>

解决方案:

  • 将Person.Name链接到Employee.FirstName
  • 将Person.Surname链接到Employee.LastName
  • 创建返回空字符串
  • 的脚本功能
  • 将Scripting functoid链接到Employee.MidName
  • 将Scripting functoid链接到Employee.Age