【问题标题】:How to map a document list in WEBMethods?如何在 WEBMethods 中映射文档列表?
【发布时间】:2014-08-27 15:37:29
【问题描述】:

我想映射一个数组,它在 WebMethods 中是一个文档列表。我认为您可以只映射该变量而不映射所有子项。我已经这样做了,但 PassArea 中没有任何显示。 (PassArea 是之后发送给大型机程序的数据数组。)

     A           -->         B
       Field1                 F1
       Field2                 F2
       field3                 F3

文档是 A,Natural 程序的输入文档是 B。--> 是将它们连接在一起的链接。

我没有要展示的图片,因为那样会泄露一些公司信息。

【问题讨论】:

  • 我会看到有关放置屏幕截图的信息。列表文档到另一个列表文档。但我发现你不能只映射你必须映射文档列表的每个字段,然后映射字段中的所有实例。

标签: webmethods


【解决方案1】:

如果文档列表“A”的字段与文档列表“B”的字段名称不同,则不,您不能将文档列表“A”映射到文档列表“B”。 WebMethods 不知道 A 中的哪个字段对应于“B”中的哪个字段。

您必须执行以下操作:

  1. 循环遍历文档列表“A”
  2. 将“A”的每个字段映射到包含与文档列表“B”相同字段的通用文档
  3. 将通用文档附加到文档列表“B”
  4. 删除通用 文件。

第 2 步截图

第 3 步截图

【讨论】:

    【解决方案2】:

    有很多方法可以在文档数组之间进行映射。但在您创建之前,请考虑以下著作:

    1. Techcommunity SoftwareAG - performance impact with appendToDocumentList
    2. quest4apps.com - Reason to avoid appendToDocumentList

    正如#2 的提示所说,它们有 6 种方式,从最快到最慢排列如下(但我将在前三种中举个例子,因为后三种很明显很慢,这被认为是可以避免的):

    1。 Java 循环:通过 Java 服务完成循环。

    • 创建java服务最简单的方法是先映射输入输出。
    • 右击并点击“生成代码”,直到出现对话框 选择选项“用于实施此服务” 并创建了服务
    • 只需将代码重新排列成这样:
    public static final void mappingDocuments(IData pipeline) throws ServiceException {
    
        // pipeline
        IDataCursor pipelineCursor = pipeline.getCursor();
        
        // Instantiate input A
        IData[] A = IDataUtil.getIDataArray(pipelineCursor, "A");
        
        // Initiate output B
        IData[] B = new IData[A.length];
        
        if (A != null)
        {
            for (int i = 0; i < A.length; i++)
            {
                // Populate the Field in doc A
                IDataCursor ACursor = A[i].getCursor();
                String Field1 = IDataUtil.getString(ACursor, "Field1");
                String Field2 = IDataUtil.getString(ACursor, "Field2");
                String Field3 = IDataUtil.getString(ACursor, "Field3");
                ACursor.destroy();
                
                // Create IData[i] and cursors finally put all Fields into B[i] variable output
                B[i] = IDataFactory.create();
                IDataCursor BCursor = B[i].getCursor();
                IDataUtil.put(BCursor, "F1", Field1);
                IDataUtil.put(BCursor, "F2", Field2);
                IDataUtil.put(BCursor, "F3", Field3);
                BCursor.destroy();
        
                // OR JUST USE CLONE BELOW IF YOU DON'T HAVE ANY MODIFICATION INSIDE THE VARIABLE
                // B[i] = IDataUtil.clone(A[i]);
            }
        }
        pipelineCursor.destroy();
        
        // Finally to put the B Map(IData) to output.
        // Actually you can use only single pipelineCursor throughout all code but it's just for readable
        IDataUtil.put(pipelineCursor, "B", B);
        pipelineCursor.destroy();
            
    }
    
    • 结果

    2。隐式循环:对于相同大小的简单列表,您可能希望在 MAP 步骤中直接链接它们

    • 创建流服务和输入输出文档
    • 创建 MAP 步骤
    • 在 ForEach 循环中选择两个文档。

    3。显式循环:使用 LOOP 步骤及其输出数组。

    • 创建流服务和输入输出文档
    • 创建循环步骤
    • 改变LOOP的属性,输入array=A;输出数组=B;并在 LOOP 步骤下创建地图
    • 将 A 中的所有参数映射到 B

    希望这些对您有所帮助...

    【讨论】:

    • 所有编译、构建和测试都在 webMethods 9.12 版本中
    猜你喜欢
    • 2016-02-12
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 2021-09-29
    • 1970-01-01
    • 1970-01-01
    • 2021-01-04
    相关资源
    最近更新 更多