BizTalk FlatFile/CSV 架构

BizTalk FlatFile/CSV Schema

我正在重构 BizTalk 应用程序。 现有模式具有以下结构,表示发票,其中 Level1 是抬头,Level 4 是多个行项目。

在旧的 2010 版应用程序中,它一次写出一张发票的数据,并且有一个使用平面文件模式的发送管道。我们正在努力改进旧系统并将其移至 2013 年。

我添加了一个接收管道来读回数据,它适用于单个发票。但如果文件中有几张发票,它就会失败。

我能否修改已有的架构(相对于必须重新 运行 向导)以允许同一文件中的多个发票?比如添加一条"Invoice"记录,同时包含Level1和Level4?

[最终目标是也添加一个 0 级,其中包括一天的总发票,并根据我们的架构师的偏好在地图和管道中执行此操作。]

我尝试了以下操作,但收到此错误:

Reason: Unexpected end of stream while looking for: ','

我使用了与 BizTalk FlatFile Schema multiple repeating records 类似的步骤:

  1. Added an Invoice record, and put Level 1 and Level 4 under it.
  2. Set the record to unbound
  3. Set Child order Infix
  4. Child delimiter type to Hex
  5. Child delimiter to 0x0D 0x0A

如果我尝试 "Child Delimiter" - "None",则会收到此错误:

Reason: Unexpected data found while looking for: $Delimited$

然后我尝试添加 "Tag identifier"(分别设置为 "Level1" 和 "Level4")。在这种情况下,带有一张发票的文件已序列化,但带有 3 张发票的文件给出了一个神秘错误:

The Messaging Engine encountered an error during the processing of one or more inbound messages.

示例数据:

Level1,,VO,TEST01,12/17/2018,34093092-1,,12/17/2018,60,1075,0,A,,,,12/17/2018,2/15/2019,2/15/2019,,,2000,1000,,1010,1000,,,,,EP
Level4,N,1200,,,1000,INDFRT-ECO,0,,0,145.72,7,34093092-448-887,,,,,,,,,,,,,,,,,
Level4,N,1200,,,1000,INDFRT-ECO,0,,0,802.67,7,34093092-492-930,,,,,,,,,,,,,,,,,
Level4,N,1200,,,1000,INDFRT-ECO,0,,0,126.61,7,34093092-833-096,,,,,,,,,,,,,,,,,
Level1,,VO,TEST01,12/17/2018,34068721-1,,12/17/2018,60,1250,0,A,,,,12/17/2018,2/15/2019,2/15/2019,,,2000,1000,,1010,1000,,,,,EP
Level4,N,1200,,,1000,INDFRT-ECO,0,,0,1250,7,34068721-492-930,,,,,,,,,,,,,,,,,
Level1,,VO,TEST01,12/17/2018,34094975-1,,12/17/2018,60,595,0,A,,,,12/17/2018,2/15/2019,2/15/2019,,,2000,1000,,1010,1000,,,,,EP
Level4,N,1200,,,1000,INDFRT-ECO,0,,0,142.8,7,34094975-448-887,,,,,,,,,,,,,,,,,
Level4,N,1200,,,1000,INDFRT-ECO,0,,0,452.2,7,34094975-492-930,,,,,,,,,,,,,,,,,

这是一个将解析您的文件的架构。

请注意,<Sequence> 节点和 Level4 的 Max Occurs 都是无界的。

使用标签时的技巧是,如果您不想首先使用空字段,则必须在标签中包含第一个分隔符或将分隔符子顺序设置为前缀。

此外,如果您的最后一行没有以 CR LF 结尾,您必须将根节点 (TAR210) 子顺序从后缀更改为中缀

您需要用正确的字段名称替换重复字段,您可以通过在重复字段之前添加它来一次完成一个字段,或者将此结构应用于现有架构。

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO55026928" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.SO55026928" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <b:schemaInfo standard="Flat File" root_reference="TAR210" default_pad_char=" " pad_char_type="char" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" />
      <schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="TAR210">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" child_order="postfix" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" />
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo>
            <b:groupInfo sequence_number="0" />
          </xs:appinfo>
        </xs:annotation>
        <xs:sequence maxOccurs="unbounded">
          <xs:annotation>
            <xs:appinfo>
              <b:groupInfo sequence_number="1" />
            </xs:appinfo>
          </xs:annotation>
          <xs:element name="Level1">
            <xs:annotation>
              <xs:appinfo>
                <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" repeating_delimiter_type="char" repeating_delimiter="," sequence_number="1" tag_name="Level1" child_order="prefix" />
              </xs:appinfo>
            </xs:annotation>
            <xs:complexType>
              <xs:sequence>
                <xs:annotation>
                  <xs:appinfo>
                    <b:groupInfo sequence_number="0" />
                  </xs:appinfo>
                </xs:annotation>
                <xs:element maxOccurs="unbounded" name="Field" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="1" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
          <xs:element maxOccurs="unbounded" name="Level4">
            <xs:annotation>
              <xs:appinfo>
                <b:recordInfo sequence_number="2" structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" repeating_delimiter_type="char" repeating_delimiter="," tag_name="Level4" child_order="prefix" />
              </xs:appinfo>
            </xs:annotation>
            <xs:complexType>
              <xs:sequence>
                <xs:annotation>
                  <xs:appinfo>
                    <b:groupInfo sequence_number="0" />
                  </xs:appinfo>
                </xs:annotation>
                <xs:element maxOccurs="unbounded" name="Field" type="xs:string">
                  <xs:annotation>
                    <xs:appinfo>
                      <b:fieldInfo justification="left" sequence_number="1" />
                    </xs:appinfo>
                  </xs:annotation>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>