BizTalk 在尝试使用以下表达式 运行 Orchestration 时得到 "invalid token"

BizTalk getting "invalid token" when try to run Orchestration with the expression below

我有一项任务涉及使用 Orchestration 对多记录 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;

循环内的下一个表达式设置 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 engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'BizTalk_SelfStudy_Week_4_Project.BizTalk_Orchestration1(ae65e0c4-9db7-6f19-1e08-6f4fbe08affe)'. The service instance will remain suspended until administratively resumed or terminated. If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.

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

Shape name: Debatch Message

ShapeId: 6ee14c8d-e55b-408b-be63-e5d83fa412a6

Exception thrown from: segment 1, progress 19

Inner exception: The part 'part' of message 'InternalCust' contained a null value at the end of the construct block.

Exception type: NullPartException Source: Microsoft.XLANGs.Engine Target Site: Void ConstructionCompleteEvent(Boolean) The following is a stack trace that identifies the location where the exception occured

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

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

正如 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 替换到其中。

它可能应该如下所示,它告诉它 select 的哪个 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);

它也有助于 Debug an Orchestration which would have allowed you to see that the XPath didn't include the Record Number and to test the Xpaths produced, a tool useful for this is Dan Sharps XML Viewer