-1

我有一项任务涉及使用编排对多记录 XML 文件进行分批,然后根据一个字段的值对其进行排序。循环外的第一个表达式获取记录计数:

recordCount = System.Convert.ToInt32(xpath(CustFile,("count/*[local-name()='Root' and namespace-uri()='']/*[local-name()='People' and namespace-uri()='']/*[local-name()='Customer' and namespace-uri()='']")));

counter = 0;

recordNumber = 0;

循环内的 Next Expression 设置 Xpath 值:

sXPath = System.String.Format("/*[local-name()='Root' and namespace-uri()='']/*[local-name()='People' and namespace-uri()='']/*[local-name()='Customer' and namespace-uri()='']", recordNumber);

下一个表达式定义了最终消息:

InternalCust = xpath(CustFile,sXPath);

最后一个表达式增加记录计数器以使循环返回并从下一条记录重新开始:

counter = counter + 1;

我想我可以管理输出消息的排序,但是当我尝试按原样运行它时,我在控制台中收到以下错误:

xlang/s 引擎事件日志条目:未捕获的异常(请参阅下面的“内部异常”)已暂停服务“BizTalk_SelfStudy_Week_4_Project.BizTalk_Orchestration1(ae65e0c4-9db7-6f19-1e08-6f4fbe08affe)”的实例。服务实例将保持挂起状态,直到以管理方式恢复或终止。如果恢复,实例将从其上次持久状态继续,并可能重新引发相同的意外异常。

InstanceId:4a2d7256-4882-4853-8f7c-6e6054e78c4c

形状名称: 发送消息

形状 ID:6ee14c8d-e55b-408b-be63-e5d83fa412a6

抛出异常:段 1,进度 19

内部异常:消息“InternalCust”的“部分”部分在构造块的末尾包含空值。

异常类型:NullPartException 源:Microsoft.XLANGs.Engine 目标站点:Void ConstructionCompleteEvent(Boolean) 以下是标识异常发生位置的堆栈跟踪

在 Microsoft.XLANGs.Core.Part.ConstructionCompleteEvent(Boolean fKillUnderlyingPart) 在 Microsoft.XLANGs.Core.XMessage.ConstructionCompleteEvent(Boolean killUnderlyingPartWhenDirty) 在 BizTalk_SelfStudy_Week_4_Project.BizTalk_Orchestration1.segment1(StopConditions stopOn) 在 Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)

我很茫然,因为我试图验证 xpath,而我得到的只是验证器上的无效令牌消息。任何人的想法?

4

1 回答 1

0

正如 Johns-305 所指出的,您对 XPath 的构造是错误的

sXPath = System.String.Format("/*[local-name()='Root' and namespace-uri()='']/*[local-name()='People' and namespace-uri()='']/*[local-name()='Customer' and namespace-uri()='']", recordNumber);

它缺少一个占位符,例如“{0}”,它将替换recordNumber。

它可能应该如下所示,它告诉它选择哪个 Customer 实例。

sXPath = System.String.Format("/*[local-name()='Root' and namespace-uri()='']/*[local-name()='People' and namespace-uri()='']/*[local-name()='Customer' and namespace-uri()=''][{0}]", recordNumber);

它还有助于调试一个可以让您看到 XPath 不包含记录编号并测试生成的 Xpaths 的编排,对此有用的工具是Dan Sharps XML Viewer

于 2017-07-20T00:41:33.927 回答