Managing Services Using Templates

The template is used for defining the response of the service. By default, every service has one template which is used for the response of the service. One service can also have more than one response based on request or the test conditions. In this case, the user needs to add multiple templates. Another situation is when the service has two responses – one for a successful response and one for error response. In this case, the user needs to define two templates. In the case of multiple templates, the user needs to provide condition logic for the selection of the template for the service response. NetOcean evaluates the condition of all the templates in sequence and uses the first template whose condition is met. If there are no templates with the matching conditions, then no response is sent. Users can have one template with no condition which becomes the default template in case no condition is met.

Adding a Template

  1. Click a service name and then click the Template Settings menu . The All Templates window is displayed.

Note: A user can adjust the width of table columns. If the table width is exceeded with the screen width, a horizontal scroll bar is displayed at the bottom. This allows the user to view the conditions which exceed the column width.

  1. Click the Add button to add a new template. The Add Template window is displayed.

  1. Enter the following properties for the template as displayed below:
  • Template Name: Unique name of the template within this service.
  • Active: Select this checkbox to make this template active. If the template is not active, then the template is not used for the response.
  • Content-Type: Content type signifies what kind of content the recipient is (supposedly) dealing with. Select the response content type if applicable. Response content type is used to put in the header in the response. The Content-Type property of the header specifies the HTTP content type for the response. If no Content-Type is specified, the default is text/HTML. Content-type: application/json; charset=utf-8 designates the content to be in JSON format, encoded in the UTF-8 character encoding. Content-type “application/json” support is provided for normal mode and RTC mode.
  • Template Mode: Two modes of template in a service:
    • Simulate: This template type indicates the simulation of service on NetOcean. If template type is ‘Simulate’, then NetOcean responses for corresponding request.Example:RESPONSE_TEMPLATE temp Simulate http: service_temp active NA.
    • Forward: This feature is used to forward request from NetOcean to a specified endpoint. User is able to configure forward request from response template type and API. If service template is configured as forward request, NetOcean saves IP/hostname, port and protocol of the end point where request is forwarded. NetOcean then forward the request, retrieve the response from backend endpoint and send it back to the client. Limitations: Redirection does not work.
      • Protocol: There are three options – ‘HTTP’, ‘HTTPs’, and ‘Same as Request’.
      • Host/IP: Provide Host/IP Address. For example:
      • Port: If you select the protocol as HTTP, the default value is 80 and if you select the protocol as HTTPs, the default value is 443. If you select the Protocol as ‘Same as Request’, the default value is 80,443. You can provide custom port also (HTTP, HTTPs).

      Note: If ‘Forward Mode’ is disabled at the Global level and you do not change the template mode from simulate to forward then a warning is displayed in the screen.
      Forward mode is disabled at global level, Please enable it to reflect your changes in the forward mode.

  • Sample Request: Sample request of the service. This is used for testing and for selection of Prefix and Suffix in Request Parameters.
  • Response Template: Response of this service for this template. User can parameterize it later using different types of parameters.
  • Additional Settings: In additional settings, user can add Template Based Headers, Template Based Service Time, Template based trace level, Template based Content Length Indicator.
  • Formatted View: This section is used to format the text using Smart Editor.

  1. Click the Save button to save the template and to go back to Templates window.

Parameterization of Response

In most cases, response needs to be parameterized using different type of parameters. Before parameterizing the template, the user needs to define all parameters needed for the parameterization of the response.

Steps to Parameterize Template Response

  1. Click Templates tab. Available templates window is displayed.

  1. User needs to click the template he/she wish to edit. Edit template window appears. Make sure Response Template radio button is selected and response is displayed in the text box.
  2. Select text in the response which needs to be parameterized.
  3. Select Replace selected text by parameter and the parameter name and click Apply.

  1. Selected text is replaced by parameter name enclosed in curly braces as displayed below:

  1. Click the Save button to save the changes.
  2. To activate the changes, click the Activate button on NetOcean services window. To test the changes, click user Test functionality.

Using these steps, user can parameterize other text with any of the parameter based on the testing requirements of the service.

  • Action: This is the action perform by user to parameterize the response. On click on action dropdown list following options are provided:
    • Replace selected text by parameter: This means, replace the selected text (block) by parameter name. After selecting this option, provide parameter name. On the basis of selected parameter name, user’s response is parameterized.
    • Replace selected text by sequence number: In this case, the selected text is replaced by a number. This number is increased by 1 every time. User needs to define the starting sequence number.
    • Mark selected block repeatable: Using this, user can define that how many times the selected area of text need to repeat.

Here, user has following options:

Value of a parameter: When user selects this option then the selected block is repeated on the basis of parameter value. After selecting this option user needs to provide parameter name in next option.

Number of occurrence of Search parameter: This option used when provide occurrence count (ORD) = All in search parameter, then use this value so that it can replace the selected block by no. of occurrence of LB and RB counts come in request. After selecting this option, provide the search parameter name in select parameter option.

Fixed number: In this option, provide the fix number which repeats the selected text on the basis of that number.

  • Replace selected text by system date parameter: Select the text and replace the text with system date of specified format. User need to specify the date format also.
  • Direct access from request parameter: In this option, direct access from request parameter is performed. User needs to provide the Attribute name.
  • Direct access from query parameter: In this option, direct access from query parameter is performed. User needs to provide the Query name.
  • Direct access from xml parameter: In this option, direct access from xml parameter is performed. User needs to provide the XML Node path.

Selecting Condition of a Template

If more than one template is used, then user needs to provide condition for the selection of all additional templates. Conditions can be defined on the basis of variable values or request.

Steps for adding condition of a Template

  1. Expand Add condition for the selection of this template.

  1. Select following argument for the condition:
  • Parameter Name: Parameter name to be used in the condition.
  • Type: Type of parameter – String or Numeric.
  • Condition Operator: Select condition operator:
    • Equal To
    • Not Equal
    • Greater Than
    • Less Than
    • Greater Than Equal To
    • Less Than Equal To
  1. Right Hand Side: Select any parameter or constant value
  2. Click Add to add this condition.
  3. To add more conditions for this template, select Logical Operator (AND or OR) and add condition using above steps.
  4. After condition is added, it is displayed in the Applied Condition text box. For example, following condition has two conditions with logical operator of AND. This condition is try if value of Amount variable is >= 10 AND <= 100.


User can add template based headers, template based service time, template based trace level, and template based Content Length Indicator by using the Action section of the Template window.

Add Template based Headers

NetOcean sends following headers in the service response:

  • Content-Length
  • Content-Type – If content type was select for the template.
  • Any additional header specified in global header files
  • Any header added using C API used in the Callback methods

Using HTTP header setting, user can send additional HTTP headers in the response for the service. To add template based headers, click the  icon on the templates page. A pop-up window is displayed. Add additional HTTP headers for that template and click Save.


  1. ‘Template Based Headers’ has higher priority than ‘Service Based Headers’.(Example:- ‘Service Based Headers’ will be overridden if ‘Template Based Headers’ is defined in that Service.)
  2. Template based ‘Content type header’ has higher priority than Service based ‘Content type header’.(Example:- Service based ‘Content type header’ will be overridden if Template based ‘Content type header’ is defined in that service.)

Add Template based Service Time

Response time delay or service time delay is the time taken between request sent by the client and the response received by the client. The user can check the time delay between client and server and see its value.

NetOcean sends response of the service as soon as the request is received. So there is no delay in the Response. User can add service time delay by using Service Time Delay settings. To add template based service time, click the  icon on the templates page. A pop-up window is displayed to add service time delay.

To use template based service time, select the Enable Service Time check box. There are following options under this section:

  • No Service Time: On selecting this, no service time delay is applied.
  • Exponential Random Service Time: On selecting this, exponential random service time with median of specified seconds is applied. For exponential random distribution, median is roughly around 1/4th of the mean.
  • Constant Service Time: On selecting this, the user can get the service time delay along with the services after Http Recording.
  • Random Service Time: On selecting this, user needs to specify random (uniform distribution) service time from a range of specified seconds.

Click Save.

Add Template based Trace level

To add template based trace level, click the  icon on the templates page. A pop-up window is displayed to add trace level. Specify the Trace level, and click the Save button.

  • Disabled: No logs.
  • Log URL and Parameter: Request arrival time, URL, client IP, port, request file, service time, template name, response file, response time.
  • Log URL, Parameter, and Request/Response: Level 1 + parameters names and their values applied to that service.

Add Template based Content Length Indicator

Content Length Indicator allows a user to transfer data into a series of overlapping chunks. To add template based Content Length Indicator, click the  icon on the templates page. A pop-up window is displayed to enable Content Length Indicator.

Once the user selects the Enable Content Length Indicator check box, more options are displayed. The user must select the Mode as Enable, and then choose from two options in the Chunk Scheme drop-down: Size of chunk and Number of chunks. The check box for Default size of chunk / Default number of chunks is selected by default. The user must clear the check box to enter a value other than the default value. Click Save. The default size of a chunk is 1440 bytes and the default number of chunks is 2.

Add Template Based Forward Settings

You can mention the forward settings in the advanced settings. These settings include – Forward Request Header, SSL Settings, General Settings, and Modify Forward Response Settings.

Forward Request Header: You can provide the Request Header in the forward Mode. There are following options:

  • Mode: There are three modes available for the Forward Request Header – Add, Modify, Delete
  • Header and Values: You can provide the header and values for the Request header.

Example: Content-Type:json


  • If you select the delete option in Mode, you do not need to provide the header values.
  • You can delete a header by clicking the

SSL Settings: You can provide the following SSL settings in this section:

  • TLS Version: You need to provide the TLS Version. Following options are available:
    • All version(s)
    • TLS 1.0
    • TLS 1.1
    • TLS 1.2
    • TLS 1.3
  • SSL Renegotiation: A number of Internet connections require SSL renegotiation, a Secure Sockets Layer/Transport Layer Security process that allows the changing of the details of a handshake after a connection is made with the server. There is a checkbox for the SSL Renegotiation, you can enable/disable it.
  • Cipher Suite: A cipher suite is a set of algorithms that help secure a network connection that uses Transport Layer Security (TLS) or its now-deprecated predecessor Secure Socket Layer (SSL). There is a list of cipher suite from where you can select the required ones.
  • Server Require Authentication for Client Certification: If you enable this check box, you need to provide the certificate.
    • Certificate File: The uploaded certificate file will be saved in the service directory.
    • Key File: On selecting the ‘Separate Key File Required’ checkbox, you need to upload the key file. The key file will also be saved in the service directory.

 General Settings: There are following general settings available in this section:

  • Forward Percentage: It is the % of request to be forwarded, the remaining will be served in simulated mode. The forward percentage should be in the range (0-100) up to 2 decimal places. Example: If you mention the percentage as 20%, then the remaining 80% will be served as a simulate mode.
  • Enable Service Time: In Forward mode, since the response is coming from the backend, there is no need to apply service time. However, in some cases, service time may be required and in that case, you can select the ‘Enable Service Time’ checkbox. Response time will the max of service time or the backend response time.


    • If the backend response time is 100 ms and the service time is 200 ms, the client request time will be 200 ms.
    • If the backend response time is 300 ms and the service time is 200 ms, the client request time will be 300 ms.
  • Replace/Add HOST Header in the Forward Request: If the host header is coming in the request, it will be replaced.
  • Connection Timeout: You can provide the connection timeout option at the template level also and it will be treated as a high priority.
  • Response Timeout: You can also provide the Response timeout at the template level.

Modify Forward Response Settings

You can modify the forwarded response if in-case forwarded response has any error/incorrect response fields. This helps in avoiding false/incorrect responses to applications from forwarders.

  • You can provide this configuration in case of forward mode only.
  • These settings are on template as well as service level. Priority of template level setting is higher.

  1. Go to the Modify Forward Response Settings section and provide the following details:
    • Occurrence Count: It is a dropdown with options, such as Index, ALL, ANY, LAST. If you select index, another integer text box becomes active in which you need to provide the index number (must be greater than zero). Default is INDEX with value 1.
    • Ignore Case: A checkbox is there with default value checked/enabled.
    • Field Name: You need to provide the field name for which you want to replace the values.
    • Current Value: There are some pre-defined values displayed in the drop down.
    • Updated Value: You need to provide the updated value for that field.
  1. Add the details and Save.


  • You can delete either all or selected records in the table. For the multi deletion approach, there is a checkbox given in the table (corresponding to each record). If you want to delete multiple entries then the delete button is displayed else not. For single deletion, you can remove it from the action menu.

  • To update any record, click the Edit button. All the values are filled in the text boxes and you can update accordingly.