Description

The SOAPSegmentMergeReceiver merges from two or more segmented data files generated from the SegmentDataCreatorReceiver, into one or more nested XML formatted files. 


This Receiver merges different segment data created by SegmentDataCreatorReceiver into a complex nested XML payload that is sent to an endpoint via SOAP request.


In This Article


When should this Receiver be used? 

  • Any time you want to generate nested SOAP output.


When should this Receiver not be used? 

  • Any time you want to generate another type of nested output.


Are any additional items required to use this Receiver? 

  • SegmentDataCreatorReceiver- Must be assigned to each Domain, except the Merge Domain.
    • Note: The SOAPSegmentMergeReceiver should only be assigned to the Merge Domain that merges the generated segments.

  • Configuration File - Used to determine the XML output format. This is typically named "config.xml" but can be named differently if needed. 
    • Note: When named differently, the name must also be changed for the configName parameter within the Receiver.

  • Template Files - Referenced within the configuration file to determine the XML output format.


List of Steps to Generate a Complex Nested XML Payload

  1. Set up a Project with Domains, Parent-Child Relationships, and Scenarios.
  2. For each Domain except the Merge Domain, complete the following: 
  3. Create a Merge Domain with just an id Attribute 
    • Note: This may have already been done if Domains were imported.
  4. Add the SOAPSegmentMergeReceiver to the Merge Domain and configure it, as discussed in this article. 
  5. Create a Scenario Chain with all Domain Scenarios. Make sure the Merge Scenario is in the last position.
  6. Create a Configuration File as discussed in this article. 
  7. Download the Scenario Chain to your local computer.
  8. Download the Configuration file to your local computer. 
    • Note: The configuration file will need to be placed in the location defined here (see the image below):


Receiver Parameters

The SOAPSegmentMergeReceiver requires that the following parameters are defined. Items with an asterisk* are required.

  • outputPath* - Defines the location to store the newly generated SOAP request and response.
  • outputSubDir - Defines the subdirectory within the Output directory where the output will be generated.
  • configPath*- Defines the location where the configuration file will be stored.
  • configSubDir - Defines the subdirectory under the configPath directory where the configuration file will be stored.
  • configName* - Defines the name of the configuration file.
  • connectTimeout* - Defines a timeout in seconds for the connection to the SOAP service.
  • readTimeout* - Defines the timeout in seconds and how long to wait for a reply from the client.
  • useCaches* - Defines whether the WSDL will be cached and modifications updated.
  • followRedirects* - Defines whether the response can follow redirects.
  • deleteOutputSubDir - Defines whether to delete the generated or an existing outputSubDir or not during the execution of the Scenario.
  • sslTrustAllCerts* - Defines whether all SSL Certificates should be automatically trusted.
  • overrideFileName - Defines the fileName, which will override the fileName provided in the configuration file.
  • segmentPath* - Defines the path to the Segment directory where all segment subdirectories can be found.
  • segmentSubDir* - Defines the subdirectory under the segmentPath where segment files can be found.
  • filesPerOutputSubDir* - Defines the number of files to be generated per output subdirectory.


Receiver Attribute Property Keys

There are no property keys necessary for this Receiver.


Example Account Story

In this basic use case, a user wants to insert N no. of records of account types in the database via SOAP request.


So, the example below will be based on the generation of segmented data for an AccountType Domain. There is an AccountType Domain:

  • AccountTypeDomain is the root Domain


The AccountType Domain will use a SegmentCreatorReceiver to generate segmented data output. The last Domain, Merge, will use a SOAPSegmentMergeReceiver to merge the segmented data generated into one or more XML output files.

Two Scenarios will be created containing the instruction on how much the segmented data to generate for an AccountType Domain. Lastly, the Scenarios can be chained together so that they can be run with one command instead of two separate commands.



Configuration File

The configuration file defines the following elements of information:

  1. url - defines the endpoint for the SOAP request.

  2. fileNameSegments - contains subelements that define how file names are created for each nested XML generated. 

  3. templateFiles - contains subelements that define the template file to read and an optional segment to read for the merge process.

  4. segments - contains nested segments that define the nesting of the templates that will define the XML output.

Steps to Create Configuration File

  • Within the Project Dashboard, select the Configuration Management Tab within the Management pane.
  • Click the New Configuration button.



  • Select the SOAP radio button in the Select Config Type dialog window.
  • Click Select.



  • Enter the required parameters to create a configuration file.
    • Name: Defines the unique name for the JSON configuration.
    • Request URL: Defines the endpoint for the SOAP request.
    • Config File Name: Defines the name of the configuration file that SOAPSegmentMergeReceiver will read to create SOAP request payload.
    • Segment Indent Level: Defines the indentation for nested XML payload.
    • Output File Name Prefix: Defines the prefix for the name of the output file.
    • Log Request: Defines whether to log the sending request in a file.
    • Log Response: Defines whether to log the receiving response in a file.
    • Template Files: Defines the various segment and template files that will be used to build nested XML.



  • Arrange the Segments in a hierarchy by dragging/dropping the segments (Note: In this example, only one segment is used).
    .

Steps to Download the Configuration File

Once the configuration file has been created within the GenRocket web platform, the user must download it to their local machine and any other required files (e.g., Scenario, Scenario Chain, Scenario Chain Set, Test Data Cases).

This can be done by clicking on the Download (Cloud) icon for the configuration file within the Configuration Management Tab.


The user must copy or cut/paste the configuration file to a "config" subdirectory located in the path defined for their resource.output.directory Organization Resource.


Note: If the subdirectory value has been changed within the SOAPSegmentMergeReceiver, the configuration and template files must be placed there.



Example Configuration File

This is an example configuration file defined to allow segment file(s) to be merged into one or more XML nested output files.


The XML configuration file

The following is a preview of the XML configuration file, which will produce the log request and response XML files based on the settings provided in the configuration file.


<config>
  <url>http://localhost:8091/GrailsBankingDemo/services/bank</url>
  <fileNameSegments logRequest='true' logResponse='true' fileNamePrefix='AccountType' />
  <templateFiles>
    <templateFile tag='accountType' templateFile='AccountTypeTemplate.xml' segmentFile='AccountTypeSegment.xml' />
  </templateFiles>
  <segments indentLevel='2'>
    <segment tag='accountType' />
  </segments>
</config>


The example configuration file defines the following information.


FileNameSegments

The subelements will produce a file naming convention that looks like the following:

  • AccountType-Request-1.xml
  • AccountType-Request-2.xml
  • AccountType-Request-3.xml


TemplateFile(s)

The following template file will be loaded and used to create the XML output when merged with segment data.

  • AccountTypeTemplate.xml


SegmentFile(s)

The following segment file will be loaded, and the data used in the merge process.

  • AccountTypeSegment.xml


Segment

The nested segment(s) determine the sequence and structure of the nested XML output.

 

<accountType>


Template File(s)

Each template file below represents a block of XML elements used for merging with segment data that, combined together, will create a nested XML file.


AccountType Template

This template will be used for data segment merging with <segment name="accountType">

<template>
    <header/>
    <body>
        <line><![CDATA[<xs:Envelope xmlns:xs='http://schemas.xmlsoap.org/soap/envelope/'>]]></line>
        <line><![CDATA[    <xs:Body>]]></line>
        <line><![CDATA[        <ns1:createAccountType xmlns:ns1='http://bank.genrocket.com/'>]]></line>
        <line><![CDATA[            <name>@name@</name>]]></line>
        <line><![CDATA[        </ns1:createAccountType>]]></line>
        <line><![CDATA[    </xs:Body>]]></line>
        <line><![CDATA[</xs:Envelope>]]></line>
    </body>
    <footer/>
</template>


Example Files

All of the example files below were generated by GenRocket.


Example merged nested Request XML file

The following is an example of a merged XML request file for the first account type generated.


<xs:Envelope xmlns:xs='http://schemas.xmlsoap.org/soap/envelope/'>
    <xs:Body>
        <ns1:createAccountType xmlns:ns1='http://bank.genrocket.com/'>
            <name>Saving</name>
        </ns1:createAccountType>
    </xs:Body>
</xs:Envelope>


Example Response XML file

The following is an example of a response XML file for the first account type generated.


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <ns2:createAccountTypeResponse xmlns:ns2="http://bank.genrocket.com/">
            <AccountType>
                <id>1</id>
                <name>Saving</name>
            </AccountType>
        </ns2:createAccountTypeResponse>
    </soap:Body>
</soap:Envelope>


Example Segment File(s)

The following is an example segmented data file used to generate the merged nested XML files.


AccountTypeSegment.xml 

This file will contain three segments, each having one data element containing the accountType attributes, a loopCount equal to one, and no parentId since the accountType is the root Domain and does not have a parent Domain.


<segments>
  <segment loopCount="1">
    <data>
      <attribute name="id">1</attribute>
      <attribute name="name">Saving</attribute>
    </data>
  </segment>
  <segment loopCount="1">
    <data>
      <attribute name="id">2</attribute>
      <attribute name="name">Checking</attribute>
    </data>
  </segment>
</segments>