webmethods - 将 DocumentList 中第 i 个文档的字段设置为 String

标签 webmethods

平台:SoftwareAG WebMethods 8.2 问题:我有 2 个 DocumentList。其中之一包含 XOPObjects 和其他字符串。我必须将 XOPObject 转换为 String 并将其复制到其他 DocList 的相应 String 字段。怎么了?没有。当很好地生成 XOPObject 的 base64string 时,String 字段仍然是条目。

使用 Given DocList:A(Source with XOP) DocList:B(Target with String field) 执行的步骤

 1. Loop over A
 2. Create Base64String from XOPObject using pub.soap.utils:getXOPObjectContent
 3. Call pub.flow:debugLog to check if the base64String is generated
 4. Generate index variable from $iteration with pub.math:subtractInts as index:=$iteration-1
 5. Perform map step from base64String to B's String field with index set to %index%
 6. After loop
 7. pub.xml:documentToXmlString to generate xml representation of the B document
 8. pub.flow:debugLog
 9. Nothing is in the String field...

知道这里出了什么问题吗?

最佳答案

在 webMethods Integration Server 流服务中,循环有两个属性来标识要迭代的列表:一个输入数组,它是必需的,一个输出数组,它是可选的。

循环步骤的工作方式是它只保留对输入和输出数组中的项目所做的更改;如果您更改管道中任何其他列表中的项目,则这些更改会在循环步骤退出时丢失。这就是它的工作方式。

引自 webMethods Developer User's Guide 的第 198 页:

Specifying the Input Array

The LOOP step requires you to specify an input array that contains the individual elements that will be used as input to one or more steps in the LOOP. At run time, the LOOP step executes one pass of the loop for each member in the specified array. For example, if you want to execute a LOOP for each line item stored in a purchase order, you would use the document list in which the order’s line items are stored as the LOOP’s input array.

You specify the name of the input array on the LOOP step’s Properties panel. The array you specify can be any of the following data types: * String list * String table * Document list * Object list

The LOOP step executes once for each member of the array specified in Input array.

When you design your flow, remember that because the services within the loop operate against individual elements in the specified input array, they must be designed to take elements of the array as input, not the entire array.

Loop Step Properties

For example, if your LOOP executes against a document list called LineItems that contains children called Item, Qty, and UnitPrice, you would specify LineItems as the Input array for the LOOP step, but services within the loop would take the individual elements of LineItems (for example, Item, Qty, UnitPrice, and so forth) as input.

Collecting Output from a LOOP Step

If your LOOP step produces an output variable, the server can collect that output into an array in the pipeline.

To do this, you use the Output array parameter to specify the name of the array variable into which you want the server to collect output for each iteration of the loop. For example, if your loop checks inventory status of each line item in a purchase order and produces a String called InventoryStatus each time it executes, you would specify InventoryStatus as the value of Output array. At run time, the server will automatically transform InventoryStatus to an array variable that contains the output from each iteration of the loop.

To collect output from each pass of the loop, specify the name of the output variable that you want the server to collect for each iteration.

鉴于所有这些,实际上有几种不同的方法可以解决您的问题:

  1. 在循环步骤的输出数组属性中指定您的第二个文档列表变量名称。这样做会在循环步骤退出时保留您对第二个文档列表所做的更改。

  2. 在循环步骤之前的映射步骤中获取第一个文档列表(带有 XOPObject 对象的文档列表)的副本,然后循环遍历副本而不是原始副本,并内联改变副本的项目。

  3. 在循环步骤中使用pub.list:appendToDocumentListpub.list:appendToStringList 分别构造一个新的Document List 或String List。这需要更多代码,在您的情况下没有必要,因为您希望输出列表为输入列表中的每个项目都包含一个项目,但是在过滤掉输入列表项目时很有用(即生成的输出列表将是输入列表的子集)。

关于webmethods - 将 DocumentList 中第 i 个文档的字段设置为 String,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21775551/

相关文章:

webmethods - 如何遍历字符串列表的映射(带有迭代器)并使用 InputArray 的值加载另一个字符串列表?

http - 如何从 webMethods com.wm.net.NetException 获取 HTTP 状态?

webmethods - 我可以使用什么转换器将日期转换为 YYYY - MM - DD 格式,最终结果中没有时间格式?

javascript - jQuery 无法将 'connect' 与我服务器生成的网页上的元素一起使用

linux - Linux 上的 WebMethods 集成服务器

webmethods - 将 Web 方法文件夹移动到 webMethods 中?

java - Webmethods 从 IData 获取文档引用的类型

java - Lucene 文本搜索以非字母结尾的名称失败