我有一个 BizTalk 2016 / VS 2015 解决方案。有一个简单的平面文件模式,通过将重复记录元素的“Max Occurs”属性设置为 0 来分批每一行。
架构的“配置”部分如下所示:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF" 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="true" early_terminate_optional_fields="true" allow_message_breakup_of_infix_root="true" compile_parse_tables="false" root_reference="Employee" />
</xs:appinfo>
</xs:annotation>
<xs:element name="Employee">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0xA" child_order="postfix" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
<b:properties>
<b:property distinguished="true" xpath="/*[local-name()='Employee' and namespace-uri()='http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF']/*[local-name()='Data' and namespace-uri()='http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF']/*[local-name()='NiNumber' and namespace-uri()='http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF']" />
<b:property distinguished="true" xpath="/*[local-name()='Employee' and namespace-uri()='http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF']/*[local-name()='Data' and namespace-uri()='http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF']/*[local-name()='OrgLeaveDate' and namespace-uri()='http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF']" />
<b:property distinguished="true" xpath="/*[local-name()='Employee' and namespace-uri()='http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF']/*[local-name()='Data' and namespace-uri()='http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF']/*[local-name()='PosLeaveDate' and namespace-uri()='http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF']" />
<b:property distinguished="true" xpath="/*[local-name()='Employee' and namespace-uri()='http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF']/*[local-name()='Data' and namespace-uri()='http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF']/*[local-name()='PostStartDate' and namespace-uri()='http://LCC.Integration.Employees.Schemas.SAP.SapEmployee_FF']" />
</b:properties>
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:appinfo>
<groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
<xs:element maxOccurs="1" name="Data">
<xs:annotation>
<xs:appinfo>
<b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0x9" child_order="infix" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
</xs:appinfo>
</xs:annotation>
<xs:complexType>
输入文件以制表符分隔,以 unix 样式的行结尾。
平面文件模式唯一有点不寻常的是,最后一个元素“PostStartDate”的 micOccurs 属性值为 0。这是因为这些文档有几个提供者,其中一个提供者不包含“ PostStartDate”列。
我已经设置了一个包含 FF 反汇编程序的接收位置。它的 DocumentSpecName 属性设置为模式的属性。所有其他属性为默认值。
此接收的唯一订阅者是发送到本地文件夹的发送端口。
如果我删除一个包含 3 行的平面文件,那么一切正常。但是,如果我再扩展几行(本例中总共 7 行),则 BizTalk 会在接收位置挂起并显示错误:“消息引擎在处理一个或多个入站消息期间遇到错误。” 在事件日志中,我看到了错误:
There was a failure executing the receive pipeline: "LCC.Integration.Common.Pipelines.RcvArchiveFF, LCC.Integration.Common.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ff3873c2d0a7e656" Source: "Flat file disassembler" Receive Port: "SharePoint.Employees.Receive.SAPExtract" URI: "D:\FileDrop\Employees\In\*.txt" Reason: Unexpected data found while looking for:
'\t'
The current definition being parsed is Employee. The stream offset where the error occured is 1813. The line number where the error occured is 8. The column where the error occured is 0.
我注意到的另一件事是,如果我从文件的最后一行中删除尾随 LF,那么它就可以工作 - 无论行数如何。
我制作了一个截屏来演示这个问题:Screencast of Problem
我创建了一个示例解决方案来演示该问题。这可在以下 github 存储库中获得:https ://github.com/RobBowman/BizTalkFFProblem
有任何想法吗?