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.


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.
  • configPath*- Defines the location where the configuration file to be stored.
  • configSubDir - Defines the subdirectory under the configPath directory where the configuration file to 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 how long to wait for a reply from client.
  • useCaches* - Defines whether the WSDL will be cached and modifications updated.
  • followRedirects* - Defines whether response can following 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.


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.


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 given 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 for 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.



Steps to Create Configuration File

  • Select the Configuration Management tab from the Management pane.

  • Click on the New Configuration button.

  • Select SOAP radio button in the Select Configuration Type.

  • 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 drag/drop the segments (Note: In this example only one segment is used).


Example Configuration File

This is an example configuration file is 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 are 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>