【问题标题】:BizTalk schema generation for a transaction with multiple records with only one tag为具有多条记录且只有一个标记的事务生成 BizTalk 架构
【发布时间】:2016-02-11 19:14:12
【问题描述】:

我有一个包含以下交易记录的数据文件

1020915  
2Suppliers - Non Consumption  
2Offer sheet needed  
3CRIV SOL  
43005t5677 

1021015  
2Shippment to New York  
3Be required to provide receipts when turning in sheets   
(Invoice was not sent in time. Copy was requested)  
43005yg876

每行记录都以标记标识符 1、2、3、4 开头。我的问题是标签为 3 的第二笔交易。请注意,该行中没有出现任何标签(发票未及时发送。要求复制)。事实上,它是一个新行,在前一行的末尾带有“LF”。如何制作一个模式来捕获这种异常?

【问题讨论】:

标签: biztalk biztalk-2013


【解决方案1】:

很遗憾,您不能,因为反汇编程序无法知道错误的 CR/LF 是记录分隔符还是实际内容。

您的问题是文件无效,它不是 BizTalk 或您的架构或您的任何东西。

因此,您需要做的第一件事就是让该文件的供应商知道他们正在发送无效内容。

如果不能或不会纠正他们的问题,您要做的第二件事是通知您的管理层,因为他们正在生成无效数据,您必须花费额外的时间来修复它。

最后,您必须为尝试检测无效 CR/LF 并替换它们的解码状态编写管道组件。请注意,这可能会变得非常棘手,因为您仍然不知道 [CR/LF]3 是分隔符还是内容。

祝你好运!

【讨论】:

  • 标签3的行是描述字段。有些用户按 Enter 键开始新的一行内容,即使他们不需要这样做,因为它会自动换行。
  • 是的,这对用户来说非常好,但它为什么会发生并不重要。由于 CR/LF 不明确,生成此文件的 eve 仍在制作无法解析的文件。他们需要最终解决这个问题。
【解决方案2】:

我认为在这种情况下你会想要编写一个自定义反汇编程序。可能有一种方法可以欺骗 FFDASM 以正确处理此问题,但这是一个非常简单的信息,并不难。 CodeProject 上有一个教程。

您的反汇编方法可能类似于:

msgPart = pInMsg.BodyPart;
Stream originalStream = pInMsg.BodyPart.GetOriginalDataStream();
StreamReader reader = new StreamReader(originalStream);
XNamespace ns = "http://schema_name_space";
XDocument returnDoc = new XDocument(new XElement(ns + "SchemaRootNode"));

while (reader.Peek() > -1)
{
   // use reader.ReadLine() to consume your lines, use the first character to determine what kind of node to put them into
   xd.Root.Add( // new XElement with your string in it based on the "tag"
                // with logic to determine whether line has a tag or not.
}

VirtualStream vts = new VirtualStream();
xd.Save(vts);
vts.Position = 0;

IBaseMessage outMsg = pInMsg;
outMsg.BodyPart.Data = vts;

pContext.ResourceTracker.AddResource(vts);
pContext.ResourceTrakcer.AddResource(reader); // BizTalk will dispose of these later

outMsg.Context.Promote("MessageType", 
  "http://schemas.microsoft.com/BizTalk/2003/system-properties",
  "http://schema_name_space#SchemaRootNode");
outMsg.Context.Promote("SchemaStrongName", 
  "http://schemas.microsoft.com/BizTalk/2003/system-properties",
  "SchemaAssembly full name");

qOutputMsgs.Enqueue(outMsg);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多