BizTalk - 带有标题多个记录和页脚的平面文件 - 反汇编问题

时间:2011-03-16 10:01:00

标签: file header biztalk flat

我有平面文件架构(下面的描述),我通过自定义管道得到平面文件(下面的描述),平面文件失败反汇编阶段,出现以下错误: 意外结束了 寻找: '\ r \ N' 正在解析的当前定义是Root。发生错误的流偏移量为202.发生错误的行号为5.发生错误的列为0。                 HRESULT:80131940

我尝试了各种选项(子命令,子分隔符等),但都失败并出现相同的错误。 我不能使用标签标识符,因为页脚和记录以相同的字符开头。

我必须在业务流程中获取完整的消息,因为我无法使用页眉,页脚预告片(预告片总是丢失)。

架构:

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://BizTalk_Server_Project1.FlatFileSchema1" targetNamespace="http://BizTalk_Server_Project1.FlatFileSchema1" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
      <b:schemaInfo standard="Flat File" codepage="65001" 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" root_reference="Root" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="Root">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0xD 0xA" child_order="infix" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo>
            <b:groupInfo sequence_number="0" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element minOccurs="1" maxOccurs="1" name="Header">
          <xs:annotation>
            <xs:appinfo>
              <b:recordInfo structure="positional" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:annotation>
                <xs:appinfo>
                  <b:groupInfo sequence_number="0" />
                </xs:appinfo>
              </xs:annotation>
              <xs:element name="Header_Child1" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="15" sequence_number="1" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Header_Child2" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="15" sequence_number="2" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Header_Child3" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="15" sequence_number="3" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="Record">
          <xs:annotation>
            <xs:appinfo>
              <b:recordInfo structure="positional" sequence_number="2" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:annotation>
                <xs:appinfo>
                  <b:groupInfo sequence_number="0" />
                </xs:appinfo>
              </xs:annotation>
              <xs:element name="Record_Child1" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="18" sequence_number="1" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Record_Child2" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="18" sequence_number="2" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Record_Child3" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="16" sequence_number="3" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element minOccurs="1" maxOccurs="1" name="Footer">
          <xs:annotation>
            <xs:appinfo>
              <b:recordInfo structure="positional" sequence_number="3" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:annotation>
                <xs:appinfo>
                  <b:groupInfo sequence_number="0" />
                </xs:appinfo>
              </xs:annotation>
              <xs:element name="Footer_Child1" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="15" sequence_number="1" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Footer_Child2" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="15" sequence_number="2" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Footer_Child3" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_offset="0" pos_length="15" sequence_number="3" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

平面文件示例:

Header Field1  Header Field2  Header Field3  
Record 1 Field 1  Record 1 Field 2  Record 1 Field 3
Record 2 Field 1  Record 2 Field 2  Record 2 Field 3
Footer Field1  Footer Field2  Footer Field3 

谢谢, 阿萨夫

2 个答案:

答案 0 :(得分:5)

雅科夫,

我可能会在这里遗漏一些东西,但我认为你不能做你想做的事 -

你有一个标题记录,其中有一个,所以BizTalk可以处理它 - 它可以假设第一个记录是一个标题记录,并根据模式正确解析它。

然后你有一个无限制的'Record'记录集,而且BizTalk也很好地处理它们 - 它会尝试将每个其他记录解析为'Record',并且根据Child Order属性,它会在之后得到一个分隔符每条记录以及文件末尾与否。

然后你有一个页脚记录,但没有标记标识符BizTalk不知道何时尝试将记录解析为页脚记录。它没有 - '文件中的最后一行'的概念。

因此它将标题记录后的所有记录解析为“记录”,然后留下寻找看似缺失的页脚记录。

解决此问题的方法是为记录类型提供标记,在您的示例中至少为页脚提供。

我已将“页脚”标记添加到页脚记录并正确解析文件(再次 - 根据子订单属性的值,最终需要返回回车

我希望这是有道理的

贝纳

答案 1 :(得分:1)

如果在要解析的文件末尾添加carraige返回。如果您的文件最后没有carraige返回,那么您可以将Footer元素上的Child Order属性更改为前缀。