Services

In this section, the user learns how to add, record a new service and manage the added services. There are two ways of creating a new virtual service.

This section covers the recording of HTTP-based service. Most of the steps are common for all protocols.

Manage Service

In the manage home page, there are following fields:

Figure 29: Manage Service HomePage

For details of fields in Manage Service , refer to Right Panel.

Manage Service can be done using the following:

  • Using Templates
  • Using Service Parameters
  • Using Service Settings

Template Settings

Using Templates

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 the 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 an error response. In this case, the user needs to define two templates. In case of multiple templates, they need to provide condition logic for the selection of the template for the service response. Service Virtualization 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

Click the Templates Settings menu  as shown in the below figure

Figure 30: Template Settings Icon

2. The All Templates window is displayed as shown in the below figure.

Figure 31: Template Settings

Note: An user can adjust the width of table columns. If the table width exceeds 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.

Service

In Service, there are following two fields:

  1. Service Name: In the service name, the user can see the name of the service whose template they can configure.
  2. End Point URL: In the end point url, it shows in which URL the service is running.

Template(s)

In Template(s), there are following fields:

  1. Order: Shows the order in which the condition will be evaluated.
  2. Template Name: It is a list that contains the number of templates available in the current service. The response comes from the selected template.
  3. Mode: There are two types of modes:
  • Simulate: This template type indicates the simulation of service on the server. If the template type is ‘Simulate’, then the virtual server responses to the request.
  • Forward: This feature is used to forward a request from the virtualized server to a specified endpoint.
  1. Service Time: Used to set the service time delay for static and correlated URL.
  2. Status: Shows the status of the job. The status can either be Active or can be Inactive.
  3. Template Selection Condition: It shows the conditions applied to the template. There will be one default template in this list.
  4. Action: In action, there are the following options:
  • Template Based Test : This option is used to test the response at the template level. For details refer to Test Service(Action) in Right Panel.
  • Template Based Header : This option is used to add a header in templates.
  • Template Based Service Time : This option is used to add service time in templates.
  • Template Based Trace Level : This option is used to add a trace level to a specific template.
  • Update : This option allows the user to update or edit the template.
  • Forward: This feature is used to forward a request from virtualized server to a specified endpoint.
  • Template Based Content Length Indicator: This indicates the length of the content. Enabling this will indicate the content length of the template.
  • Protobuf Settings: Here user can change or add the protobuf settings if required.

Note: User needs to click on the check box of the template to delete or inactive the template.

Adding a Template

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 the request or the test conditions. In this case, the user needs to add multiple templates.

Click Add button  to add a new template.

Figure 32: Add Template Button

  The Add template window is displayed.

Figure 33: Add Template

To add a template, enter the following fields:

  • Template Name: Enter the template name in this field. It is the unique name of the template within this service.
  • Response Template: It is the response of the service for this template. User can parameterize it later using different types of parameters. From the drop-down they can select the following action:

Note: Once a user selects any parameter, their corresponding parameter name will

  • Sample Request: Sample request of the service. This is used for testing and for selection of Prefix and Suffix in Request Parameters.
  • Beautify: Click the beautify icon ( ) which formats the content. From the dropdown select either CSS, Text, HTML, Javascript, XML, Json as per the requirement.
  • Action: User has the following actions type in response template and their corresponding sub fields:
  • Replace selected text by parameter: Select this option and from the corresponding sub fields select the name of the parameter name for replacing. On selecting this option, the selected text will be replaced by a parameter.
  • cav_cur_date: It will replace the selected text with the date parameter.
  • cav_http _method: It will replace the selected text with http methods.
  • cav_sequence: It will replace the selected text in a particular sequence.
  • cav_regex_url_match_pattern: It will replace the selected text with the URL pattern.
  • SOAPOperation: Replace the selected text with SoapOperation.
  • AccountSummary_Request_VAR_Associate_Number: It will replace the selected text with the account summary request VAR Associate Number.
Figure 34: Replace selected text by parameter
  • Replace selected text by sequence number: Select this option and enter the start sequence number from the corresponding sub fields to replace. On selecting this option, the selected text will be replaced by the sequence number.
  • Enter start sequence number: This indicates the start of the sequence number that the user has to provide which will indicate from where the text will be replaced.
Figure 35: Replace Selected text by sequence number
  • Mark selected text by repeatable block: After selecting this option, select from the sub fields drop down the block repeat upon the value, and enter the separator name. On selecting this option, the selected block will be repeated.
    • Select the block repeated upon: This option will select the text on which the block will be repeated.
    • Value of the Parameter: It shows the value of a parameter.
    • Number of Occurrence of parameter: Show the occurrence number of the parameter.
    • Fixed Number: The selected block will be repeated for a fixed number.
Figure 36: Mark selected text by repeatable block
    • Replace selected text by date parameter: Select this option, from the sub fields drop down select the format of date and then select the offset number. On selecting this option, the selected text will be replaced with the date format.
  • Format: Select text will replace by format.
  • Offset: Enter the offset number.
Figure 37: Replace selected text by date parameter
    • Add request parameter and replace the selected text by it: Add request parameter and in the corresponding fields enter the attribute name. On selecting this option, the added request parameter will be replaced with the selected text.
  • Attribute Name: Enter the name of the attribute.
Figure 38: Add request parameter and replace selected text by that parameter
    • Add query parameter and replace the selected text by it: Add request parameter and in the corresponding fields enter the query name. On selecting this option, the added query parameter will be replaced with the selected text.
  • Query Name: Enter the query name.
Figure 39: Add query parameter and replace the selected text by it
    • Add XML parameter and replace selected text by it: Add XML parameter and in the corresponding fields enter the XML node path. On selecting this option, the added XML parameter will be replaced with the selected text.

XML Node Path: Enter the XML Node path

Figure 40: Add XML parameter and replace selected text by it
  • 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.

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

Selecting Condition of a Template

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

Steps for adding condition of a Template

  1. Expand Add condition for the selection of this template.
Figure 41: Add Condition for selection

2. Select the following argument for the condition:

Action:

  • 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
  • IN
  • NOT_IN
  • LIKE

3. Right Hand Side: Select any parameter or constant value.

4. Click Add button to add this condition.

5. To add more conditions for this template, select Logical Operator (AND or OR) and add the condition using the above steps.

6. After condition is added, it is displayed in the Applied Condition text box. For example, the following condition has two conditions with the logical operator of AND. This condition is tried if the value of the Amount variable is >= 10 AND <= 100.

Add Template based Headers

Service Virtualization sends the following headers in the service response:

  • Content-Length.
  • Content-Type – If content type was selected 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 as shown in the below figure.

Figure 42: HTTP Header Icon

A pop-up window is displayed as shown in the below figure. Add additional HTTP headers for that template and click Save.

Figure 43: Additional HTTP Headers

Note

  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.)

Advanced Settings

  • Content Type: Here user can select the content type for their header. The Content Type property of header specifies the HTTP content type for the response. If no Content Type is specified, the default is text/HTML.
  • Compression Type: User can compress the response by using compression types – Deflate, Gzip, and BR. Selected compression type format is displayed under the Response Template.
  • HTTP Status Code: User can configure the percentage of the selected HTTP Status code to be reflected in the response of the service.
  • Enable Date header: Here user can enable date header it will help indicating the date in the header.

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.

Service Virtualization sends response of the service as soon as the request is received. Therefore, 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.

Figure 44: Template Level 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: No service time delay is applied. Helps in doing max load testing.
  • Exponential Random Service Time: Exponential random service time with a median of specified seconds is applied. This takes a random value equivalent to median time.
  • Constant Service Time: A constant service time of specified seconds. Helps in doing controlled tests.
  • Random Service Time: It is more realistic. The value is a random value between the minimum and maximum time defined. Min should be less than or equal to Max.

Click Save.

Add Template based Trace level

Service Virtualization logs important messages which are called traces. A trace level is used to determine which events the trace provider generates. To add template based trace level, click the  icon on the templates page as shown in the below figure.

Figure 45: Add Template-Based Trace Level Icon

A pop-up window is displayed to add trace level as in the below figure. Specify the Trace level, and click the Save button.

 

Figure 46: Trace Level Detail
  • Disabled: This option is used to disable the trace level. If a user selects this option, then there will be No logs.
  • Log URL and Parameter: This option is used to log a request URL with parameter details like: parameter name and its value.
  • Log URL, Parameter and Request/Response: This option will log request URL with parameter details like: parameter name and its value, Request/response.

Now click the kebab menu  on the action panel as shown in the figure below:

Figure 47: Action Kebab Menu

Notes:

  1. If the user wants to select the trace level, they need to first select the Overwrite Global Trace Level.
  2. After the user has selected the trace level, the user needs to click on the Save icon to save the trace level.

Template based Content Length Indicator

This indicates the length of the content. Enabling this will indicate the content length of the template. Content Length Indicator allows a user to transfer data into a series of overlapping chunks. To add template based Content Length Indicator, click the option as highlighted in the below figure.

Figure 48: Add Template Based Content Length Indicator

 A pop-up window is displayed to enable Content Length Indicator as shown in below figure.

Figure 49: Template Based Content Length Indicator

Once the user selects the Enable Content Length Indicator check box, more options are displayed.

  • Mode: There are two modes – ‘disable’ and ‘enable’ to specify whether the features should be disabled or enabled.
  • Chunk Scheme: There are two chunk schemes:
  • Size of Chunk: It displays the size of the individual chunk.
  • Number of Chunk: It displays the number of chunks in which the response should be served.
  • Default Size of chunk: It displays the default size of chunks in Bytes, by default the size is 1440.
  • Default Number of chunks: It displays the default number of chunks.
  • Size of chunk: 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.

Sequence shows the order in which the conditions will be evaluated. Template with the first matching condition is used for response. Default template (one without condition) is used if no other conditions match.

Note: With Template Ordering button, the user can change the sequence number of the templates in a virtual service. It helps them to simulate their services as per priority.

Forward

The forward settings are used to enable/disable the forward requests. The requests are forwarded to the next server (whose server details has to be provided in the forward text field) to serve the response. To access Forward Settings, click on the kebab icon on the action menu and select Forward as shown in the below figure.

Figure 50:Forward

Once user clicks the above option, the following page opens as shown in figure.

Figure 51: Forward Settings

These settings include – Protocol, Host/IP, Port, Forward Request Header, SSL Settings, and General Settings.

  • Protocol: This is used to specify the protocol of recording whether it is HTTP or HTTPS.
  • Host/IP: Hostname or IP address of the backend server or endpoint server is the server from where the response is captured
  • Port: By default, HTTP Port is 80. User can give another port according to configuration.

 

Forward Request Header: User 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: User can provide the header and values for the Request header. Example: Content-Type: json.

Note

  • If the user selects the delete option in Mode, they do not need to provide the header values.
  • User can delete a header by clicking the button.

SSL Settings: Secure Sockets Layer (SSL) is the standard security technology for establishing an encrypted link between a web server and a browser. This link ensures that all data passed between the web server and browsers remain private and integral.  User can provide the following SSL settings in this section.

Figure 52: SSL Settings
  • TLS Version: User needs to provide the TLS Version.

Following options are available:

  • All version(s)
  • SSL V3
  • TLS 1.0
  • TLS 1.1
  • TLS 1.2
  • SSL Renegotiation: Several 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 SSL Renegotiation, which the user 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 the user can select the required ones.
  • Server Require Authentication for Client Certification: If a user enables this check box, they 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, the user needs to upload the key file. The key file will also be saved in the service directory.

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

Figure 53: General Settings
  • Forward Percentage: It is the % of request to be forwarded, the remaining will be served in simulated mode. Forward percentage should be in the range (0-100) up to 2 decimal places. Example: If the user mentions the percentage as 20%, then the remaining 80% will be served as simulate mode.
  • Enable Service Time: In Forward mode, since 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, the user can select the ‘Enable Service Time’ check box. Response time will be the max of service time or the backend response time.

Examples:

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

Modify Forward response settings

There are the following forward response settings available:

Figure 54: Modify Forwards Response Settings
  • Occurrence count: This property is used when the source value of a search parameter can occur multiple times in a request. It indicates which instance of the value should be extracted.
  • Ignore Case: If enabled, response becomes case sensitive.
  • Field Name: User needs to provide the field name for which they want to replace the values.
  • Current Value: Select the current value from the drop down. There are some pre-defined values displayed in the drop down
  • Update Value: User can select the updated value from local directory by clicking the Add They need to provide the updated value for that field.

Parameter Settings

How to access

  1. Click Parameters Settings  menu > Service Parameters to view the service parameters.
Figure 55: Service Parameter Icon

Once the user clicks Service Parameter, the following page opens:

Figure 56:Service Parameter

Using Service Parameters

User can define various parameters associated with a service. Parameters are variables whose values could be set based on the incoming request, or user-defined to be picked from a dataset or different inbuilt functions. Parameters are used for parameterization of the response templates, in defining conditions for the selection of the template, and as an index for Indexed Datasets. Service Virtualization supports several types of parameters to hold the values for composing service responses, template selection, and data selection.

User have the following fields in Service Parameters:

  • State: Shows the status of whether the parameter is enable/disable.
  • Type: This field shows the type of parameter in the service parameter.
  • Name: It shows the parameter name given.
  • Specification. It shows the details of the particular parameter like prefix, suffix, etc.

In the Service virtualization tab, users need to click on any service name to which they want to add parameters. the Edit Service page is displayed.

Figure 57: Editing Service Parameter

Using this window, the user can perform the following tasks:

  • Delete: Delete a parameter.
  • Rename: Use this option to rename a parameter.
  • Update: Update parameter specifications. Update displays edit window of the parameter.
  • Import: Import parameters specification in the tabular format for all parameters.
Figure 58: Import parameter
  • Enable: Used this button to enable a service.
  • Disable: Used to disable a service.

System Parameter

System Defined Parameters

This section displays some system-defined parameters. These parameters are defined by the system; the user can only view these parameters. To view system defined parameters, go to Parameter Settings > System Parameters > System Defined Parameter.

Figure 59: System Defined Parameter

It has the following fields:

  • Name: Shows the name of the parameter.
  • Description: Show all systems-defined parameters.

Add Parameter

To add a parameter of a specific type, click on the parameter link of that parameter on the left pane.

All parameters are to be provided with a unique name. Parameter Name should be started with a character, followed by characters, underscore, and numbers. Special Characters are not allowed. Name should be of maximum 64 characters.  Let us discuss the different parameters that we support.

To add service parameters, click the Parameter Settings menu > Add Parameters.

Figure 60: Add Parameters

Using the parameter section, the user can add the following parameters:

  • Search Parameter
  • SearchIn Parameter
  • Request Parameter
  • SQL Query Parameter
  • URL Query Parameter
  • Scratch Parameter
  • Scratch Array Parameter
  • Data Set
  • Indexed Dataset
  • Data Time Parameter
  • Random Number
  • Random String
  • Unique Number
  • Cookie Parameter
  • XML Parameter
  • Condition Logic
  • JSON parameter

Search Parameter

Search parameters are used to hold the values for composing service responses.  The values for a search parameter can be assigned from the content of incoming service requests. The specific part of the request to be assigned is defined using the properties of the Search parameter.

Steps to add Search Parameter:

Go to Parameter Settings menu > Add Parameters > Search Parameter. The Add Search Parameter window is displayed.

Figure 61: Search Parameter

Following are the specifications of the Search Parameter:

Parameter Details

  • Parameter Name: Unique name for the parameter.
  • Prefix: The starting point from where the value is to be extracted in the request. If no prefix is provided, then the start of the request is considered as a prefix. Further, the user can specify the binary data and regular expression in the prefix by specifying the corresponding values and selecting the ‘Binary Data’ and ‘Regular Expression’ check boxes respectively
  • Suffix: The ending point up to which the value is to be extracted in the request. If no suffix is provided, then the end of the request is considered as the suffix. Further, the user can specify the binary data and regular expression in the suffix by specifying the corresponding values and selecting the ‘Binary Data’ and ‘Regular Expression’ check boxes respectively.

Note: In Prefix and Suffix, use \n, \r, and \t for new line, carriage return, and tab respectively. All other backslash (\) must be escaped using another backslash (\).

  • Binary Data: Upon selecting this check box, the user can search for a string using its ASCII code.
  • Regular Expression: Upon selecting this check box, the user can search for a string by providing a regular expression.
  • Ignore Case for Prefix/Suffix: Upon selecting this check box, the case is ignored for prefix and suffix.

Example: if prefix/suffix is set to <welcome> or <WELCOME> both cases will be applicable upon selecting this check box.

Advanced Settings

  • Search: Specifies the scope of the search, that is, where to search for the data. The possible values are:
  • Body (search only in body data, not headers) – Default is Body
  • Headers (search only in headers)
  • URL (search only in URL)
  • Occurrence Count: indicates the ordinal position or instance of the match. The default index is 1.
  • Any:Randomly one of the occurrences is captured.
  • All: All occurrences are captured.  Here parameter values are saved in an array.
  • Specified: Specified instance is captured. The default instance is 1
  • Prefix Matching Mode: This option is required if there are multiple prefixes and a single suffix in the request and the user wants to choose any prefix from those prefixes. The available options are Closest to Suffix, first in the Block, and Specified.
  • Closest to Suffix: Instance in which the prefix is closest to the suffix is captured.
  • First in the Block: The first instance within the block is captured.
  • Specified Occurence: Only specified instance is captured.
  • Start Offset: This is required if only a part of the searched value is to be assigned to the parameter. It indicates the start of offset. The offset value must be non-negative. You can also start offset from the first character of the searched value by selecting From the Beginningcheck box.
  • Maximum Length: The length of a sub-string of the found value, from the specified offset, to search for the parameter. The default is 0, indicating until the end of the string. It is enabled when Till the end check box is disabled. If the Maximum Length value is set to 5 then it truncates the last 5 characters and saves this altered data, ending from the 6th position from the last position, in the searched parameter variable.
  • Transform: Specifies any built-in transforms which need to be applied to the extracted value before it is assigned to the parameter.
Figure 62: Advanced Settings(Search Parameter)

There are the following options within this:

  • None: It represents the value as it is.
  • Reverse: It reverses the extracted value.
  • Upper Case: It transforms the extracted value in upper case.
  • Lower Case: It transforms the extracted value in lower case.
  • LTrim: It trims the white spaces (occurred at the left) from the extracted value.
  • RTrim: It trims the white spaces (occurred at the right) from the extracted value.
  • Trim: It trims the whitespaces (occurred at the left and right) from the extracted value.

Sample Request

  • Template Name: The user can view sample request contents of any template by selecting it from a drop-down list.
  • Set Prefix: This button is to set the prefix by selecting it in the sample request content.
  • Set Suffix: This button is to set the suffix by selecting it in the sample request content.
  • Beautify: It allows the user to format or beautify the request in a well-structured format. following formats are supported:
  1. CSS
  2. Text
  3. HTML
  4. JavaScript
  5. XML
  6. JSON

Searchln

SearchIn Parameter searches the data between the specified boundaries (prefix and suffix) in other parameter and saves it into a parameter. This is helpful in case you want perform nested search e.g. you have a product block which has n number of SKU’s and you want to search all SKUs from that block which otherwise need to write complex logic to extract such data.

Steps to add SearchIn Parameter

Go to Parameter Settings menu > Add Parameters > SearchIn Parameter. The Add Search Parameter window is displayed.

Figure 63: Add Search Parameter Window(SearchIn)

binary data and regular expression in the suffix by Specify the following properties for working with the SearchIn parameter:

  • Parameter Name: Unique name for the searchIn parameter.
  • Prefix:The starting point from where the value is to be extracted in the request. If no prefix is provided, then the start of the request is considered as prefix. Further, user can specify the binary data and regular expression in the prefix by specifying the corresponding values and selecting the ‘Binary Data’ and ‘Regular Expression’ check boxes respectively.
  • Suffix:The ending point up to which the value is to be extracted in the request. If no suffix is provided, then the end of the request is considered as the suffix. Further, user can specify the specifying the corresponding values and selecting the ‘Binary Data’ and ‘Regular Expression’ check boxes respectively.

       Note: In Prefix and Suffix, use \n, \r, and \t for new line, carriage return, and tab respectively.           All other backslash (\) must be escaped using another backslash (\).

  • Ignore Case for Prefix/Suffix:If the user selects this, case will be ignored for prefix and suffix.

Example: if prefix/suffix is set to <welcome> or <WELCOME> both cases will be applicable upon selecting this check box.

Figure 64: Advanced Settings(SearchIn Parameter)

Advanced Settings

  • Search: Specifies the scope of the search. Drop-down list shows all defined parameters in the service from where you can select the parameter where you want to search.
  • Occurrence Count: Indicates the ordinal position or instance of the match.
  • Any:Randomly one of the occurrences is captured.
  • All:All occurrences are captured.
  • Specified:Particular instance is captured.
  • Prefix Matching Mode: This is required if there are multiple prefixes and a single suffix in the request and the user wants to choose any prefix from those prefixes. (Default Settings- Closest to Suffix.) Usage of all the options is provided below:
  • Closest to Suffix:Instance in which the prefix is closest to the suffix is captured.
  • First in the Block:The first instance within the block is captured.
  • Specified:Only specified instance is captured.
  • Start Offset:This is required if only part of the delimited value needs to be assigned to the parameter. It defines the starting position of the portion, which needs to be extracted. The offset value must be non-negative. It is enabled when From Beginning check box is disabled. If the Start Offset value is set to 5 then it truncates the first 5 characters and saves this altered data, starting from the 6th position to the last position, in the searched parameter variable. Save Offset value can lie in the range 0-100 (inclusive of boundaries). Users can also specify whether to consider a complete length or a specified length.
  • Maximum Length:It indicates the end of offset. You can also end offset till the last character of the searched value by selecting till the end check box.
  • Transform: Specifies any built-in transforms, that need to be applied to the extracted value before it is assigned to the parameter. There are following options within this:
  • None:It represents the value as it is.
  • Reverse:It reverses the extracted value.
  • Upper Case:It transforms the extracted value in upper case.
  • Lower Case:It transforms the extracted value into lower case.
  • LTrim:It trims the white spaces (occurring at the left) from the extracted value.
  • RTrim:It trims the white spaces (occurring at the right) from the extracted value.
  • Trim:It trims the whitespaces (occurring at the left and right) from the extracted value.


Sample Request

  • Template Name: Here, the user can view sample request content of any template by selecting it from a dropdown list. All templates are listed in the drop down.
  • Set Prefix: Clicking this button sets the prefix as selected in the sample request content.
  • Set Suffix: Clicking this button sets the suffix as selected in the sample request content.
  • Beautify: It allows the user to format or beautify the request in a well-structured format. following format are supported:
  1. CSS
  2. Text
  3. HTML
  4. JavaScript
  5. XML
  6. JSON

 

 

 

Request Parameter

Request parameters are used to hold the values for composing service responses. The values for a request parameter can be assigned from the HTML Form (input elements) coming in the request.

Steps to Add Request Parameter

Go to Parameters Settings menu > Add Parameters > Request Parameter. The Add Request Parameter window is displayed.

Figure 65: Add Request Parameter

Following are the specification of request parameter:

  • Attribute Name: Attribute name for which the parameter is defined. This is the name of Form element coming in request. For example, to get the value of Request parameter ‘shipping Method’ from request:

POST /checkout/shippingpayment?event=selectShippingMethod HTTP/1.1

Host: 11.16.152.115:3894

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.24) Gecko/20111103

Content-Type: application/x-www-form-urlencoded; charset=UTF-8

Content-Length: 16

Origin: https://localhost:9773

shippingMethod=US

Then, Attribute Name is ‘shippingMethod’ and its value is ‘US’.

Note: On selecting the ‘Parameter name is same as attribute name’ check box, the parameter name is considered the same as the attribute name.

  • Parameter Name: Name of parameter to be associated with an attribute name. This name must be unique among all parameters in the service. Example: “UserId”.
  • Occurrence Count: This property is used when the source value of a Request parameter can occur multiple times in a request. It indicates which instance of the value should be extracted. The default index is 1. Select one of following:
  • Index: By selecting this, the user can define which index of occurrence needs to be picked.
  • All: If user selects this option, then the system takes all occurrence of the specified node.
  • Any: If this option is selected, then system takes any random occurrence of the specified node.
  • Start offset: This is required if only part of the delimited value needs to be assigned to the parameter. The offset value must be non-negative. Only numbers are allowed and there is no limit. It defines the starting position of the portion, which needs to be extracted means from where value of the variable started. It is enabled when from Beginning check box is disabled. If the Start Offset value is set to 5 then it truncates the first 5 characters and saves this altered data, starting from the 6th position to the last position, in the searched parameter variable. Save Offset value can lie in the range 0-100 (inclusive of boundaries). User can also specify whether to consider a complete length or a specified length.
  • Maximum length: Maximum length of the attribute value to be saved. A default value for the variable is 0. If the value is 0, then save complete attribute value. It is enabled when Till the end check box is disabled. If the Maximum Length value is set to 5 then it truncates the last 5 characters and saves this altered data, ending from the 6th position from the last position, in the searched parameter variable.
  • Action on not found: This action is taken if the cookie name is not found in the HTTP request. No cookie value can be empty which a found case is. It has the following two options:
  • Do not log message: It will not log any message.
  • Log Message: It will log all the message in the error logs.
  • Default value: Default value of request parameter if the attribute is not found in the request. It can be empty.
  • Transform: Specifies any built-in transforms that need to be applied to the attribute value before it is assigned to the parameter. This is done after Decode, if decoding is to be done.
    • Reverse: String fetched from request is reversed in the response file.
    • None: No transformation is done.
  • Encode in response Template: To encode request parameter if used in the response template.
    • Do not encode: No need to encode value in response template.
    • Encode all characters: Encode all character of value in the response template.
    • Encode specified characters: Encode only specified characters of value.
  • Decode Attribute Value: To decode or not decode the attribute value.
    • Decode: To decode when attribute value is extracted from the HTTP request. Decoding is done for URL style encoded value of the attribute. Example: %3D decode into =.
    • Do not Decode: The value is not decoded when it is extracted from the HTTP request.

SQL Query Parameter

SQL parameters are used to hold the values for composing service response, template selection, and data selection, parameterized SQL provides robust handling and escaping of user input, preventing accidental exposure of data.

Steps to Add SQL Query Parameter

Go to Parameter Settings menu > Add Parameter > SQL Query Parameter. The Add URL Query Parameter window is displayed.

Figure 66: Add SQL Query Parameter

Following are the specification of the Query parameter:

  • Query: Query is a question that is communicated formally. It can either be a select query or an action query, e.g. select name, price, size, id from items_table where skuid=S80 and price >= 1000.

Ex: *select sid, browserplugins, bpcompleted, bpabandoned, channel, trnum from rumsessiontable_master where ordertotal={ordertotal};

Types of Queries:

  • Select Query: It is used to fetch the data from the database table in a tabular format.
  • Action Query: It is used to ADD, CHANGE, or DELETE multiple records at a time. Types of action queries are as follows:
  • Append Query: It takes the set consequences of a query and adds them to a current table.
  • Delete Query: It erases all records in a hidden table from the set results of a query.
  • Make Table Query: It makes a table depending on the set consequences of a query.
  • Update Query: It is used to modify the existing records in a table.
  • Parameter Name: Unique name for the resulting dataset from the SQL query. It is automatically derived from the column names used in the query.

e.g. if the given query is SELECT balance, creditcardbalance from acc_balance where account_id=’{AccountID}’  then parameter names are auto define as balance,creditcardbalance

  • Occurrence Count: Indicates the ordinal position or instance of the match.
  • Any: Randomly one of the occurrences is captured.
  • All: All occurrences are captured. Here parameter values are saved in an array.
  • Specified: Specified instance is captured. The default instance is 1.
  • Existing DSN: It is the DSN which is already present in {active correlation} correlation.conf.
  • New DSN: If a user wants to create a new DSN, he can click on the radio button “New DSN”. Once the user clicks on New DSN, user needs to enter the following details:

DSN Details

  • Data Source Name: It is used to store information for establishing a connection to a database on a remote database server. A DNS is the saved collection of settings required to connect to an ODBC data source.
  • Host: IP/name of the database server.
  • Port: Listening port of the database server.
  • Username: It is the username of the database.
  • Password: It is the password to connect to database.
  • Database: indicates the type of database. Supported database arePostgres, MySQL, Oracle, and SQL.
  • DB Schema: It defines how data is organized within a relational database such as Table Names, Fields, Data Types, and the relationships between these entities.
  • Test DB Connection: It is used to test connection with the database.

Note: Types of query can be Select Query and Action Query.

URL Query Parameter

URL Query parameters are used to hold the values for composing service responses. The value for a URL Query parameter can be assigned from the query string of URL of incoming service requests.

Steps to Add URL Query Parameter

Go to Parameter Settings menu > Add Parameter > URL Query Parameter. The Add URL Query Parameter window is displayed.

Figure 67: Add URL Query Parameter

Following are the specification of Query parameter:

  • Query Name: Name of the parameter in the query string of a URL.

For example, if the user needs the value of the URL Query parameter ‘Address’ from URL
http://www.abc.com/index.jsp?Name=cavisson&Address=US, then Query Name is ‘Address’ and ‘US’ is its value.

  • Parameter Name: If the Query name is the same as the parameter name, then the user has to enable the Parameter name is same as the query name check box.
  • Occurrence Count: This property is used when the source value of a Request parameter can occur multiple times in a request. It indicates which instance of the value should be extracted. The default index is 1. Select one of following:
    • Index: Particular instance
    • All: All occurrences
    • Any: Randomly select one of the occurrences.

  

  • Conversion: This field is used to specify the conversion – none/encode/decode. The conversions are as follows:
  • None: This option will disable the conversion process.
  • Decode: This option is used to decode the encrypted conversion.
  • Encode: This option is used to send the data in an encrypted format.

Scratch Parameter

Scratch parameters (also called declare parameters) are used to set values in call back methods. These parameters are declared and then used in response and/or conditions.

Steps to Add Scratch Parameter

Go to Parameter Settings menu > Add Parameters > Scratch Parameter. The Add Scratch Parameter window is displayed.

Figure 68: Add Scratch Parameter

Following are the specifications of scratch parameter:

  • Parameter Name: Unique name for this parameter.
  • Default Value: If nothing comes in scratch parameter value then default value comes in place of parameter name in response.

Scratch Array Parameter

Scratch array parameter is same as scratch parameter except that here size of the variable in also define. Here the values are stored in an array.

Steps to Add Scratch Array Parameter

Go to Parameter Settings menu > Add Parameters > Scratch Array Parameter. The Add Scratch Array Parameter window is displayed.

Figure 69: Add Scratch Array Parameter

Following are the specifications of scratch array parameter:

  • Parameter Name: Unique name for this parameter. Parameter name must start with Alpha.
  • Size: Size is used to set the size of the Scratch Array Parameter.
  • Default Value: If nothing comes in scratch parameter value then default value comes in place of parameter name in response.

Dataset Parameter

Datasets are used to source the values from text files. This is a very common method for getting data by instructing Service Virtualization to take values from an external file. Data is contained in a file – either an existing file or one that user created using this GUI. In Datasets multiple set names can be defined separated by “,”.

Steps to Add Dataset Parameter

Go to Parameter Settings menu > Add Parameters > Dataset Parameter. The Add Dataset Parameter window is displayed.

Figure 70: Add Dataset Parameter

The following are the specification of Dataset parameter:

  • Parameter Name(s): Unique name for this parameter. Multiple parameter names can be provided at the same time using comma as separator to populate multiple parameters with values from the Dataset. For example: Name, Address.
  • Header Line Number: it is used to define the header line in the given file. In some situations, consider first few lines as headers. System does not consider these lines as data lines while picking data from file. By default, header line is 0.
  • Column Delimiter: This field specifies which character in data file should be considered as a column separator. By default, column delimiter is ‘,’. User can use special symbols as column delimiter.
  • First Data Line: In some situations, the user might want to start reading data from a particular line number. Therefore, they can use this field to indicate which line it should consider as first Data Line. By default, the first Data Line is 1.
  • Fetch Parameters from Header: It is to get the parameter names from header line of dataset contents by splitting it by Column Delimiter. User defines header line in the text box e.g. if header line is Name, AccountNo, CreditCardNo, Balance and column delimiter is “,” then parameters names is Name, AccountNo, CreditCardNo, and Balance.
  • Dataset File Name: It is the data file name from where the values need to take. Files with spaces in its name are not supported.
  • View: This option is used to view a dataset file.
  • Choose: By selecting this option, the user can choose an file from their local server.
  • Import: By selecting this option, the user can import file from the database server. Once the user selects this option, a dialog box appears in which the user has to enter following details:
    • Database Type: It is the type of database which is to be used.
    • URL Prefix: It is the prefix of the URL.
    • URL: It is the main URL.
    • User ID: It is the username to connect.
    • Password: It is the password to connect.
    • Query: In this field, the user has to provide the query for getting the data from the database.

 

  • Dataset Contents: Displays the content of the file. You can either input content or can get from existing file from the server by specifying Dataset File name and click on View. If the user wants to enter the contents in the tabular format, then the user has to click on the Table Format checkbox.

Advanced Settings

  • Ignore Invalid Data Lines: Selecting this check box provides user the flexibility to ignore the invalid lines present in the file or to have an error in case of an invalid line.
  • Update Value On: There are two modes available:
  • SESSION: The value of the variable is initialized only once during a session at the time of first use & is not changed during the session. Means the parameter is set once for each service request. It does not depend on how many times this parameter is used in response template.
  • USE: In this option value of the parameter is set every time it is used in the response template.
  • Row Selection Mode: there are 2-modes are available
  • Sequential: – Select rows sequentially from the beginning of the file to the end of file.
  • Random: – Select any row randomly from the file.
Figure 71: Advanced Settings(Dataset Parameter)
  • Parameter fields whose value is from file: In this field, multiple parameter values can be provided.

e.g. (Fn=<value> or<filename>)

Where n specifies the index number to refer the parameter name, the default value for parameter values is value.

Example: If dataset contents are:

/home/Service Virtualization/user1, LA

/home/Service Virtualization/user2, CA

/home/Service Virtualization/user3, NY

In parameter value, user provides F1=file, F2=value. It means the first parameter value comes from a file that is specified in the first field and the second parameter value is as specified in the second field. File can have any data (one or many lines) and the whole file content is the value of the first field. It is useful when parameter value can have multiple data lines or its data can have the file separator for example address. 

Notes:

  • A user cannot save a blank file or provide blank dataset contents. While doing so, an error message “Please enter dataset content” is displayed.
  • FILE is a mandatory argument and data-file-name specifies the file name containing the list of values for the variable(s) being declared. Format of the value file is as follows:
    • If there is only one variable being defined in the declaration, the file contains list of values with one value on a single line.
    • If multiple variables are being defined, a value of all variables would be defined on a single line and the values would be separated by “,”. Effectively, each row contains a set of values for each variable declared. The order of values in a row should correspond to the order of variable names in the declaration.
    • If the file name is a relative path (not starting with /), it is assumed relative to service directory of the test script to which these variables belong.

Indexed Dataset Parameter

Indexed Dataset Parameters are specialized Dataset parameters where values provided in data files can be selected based on an index value. The index can be assigned from any other parameter e.g. a customer id from an incoming request can be used to select a row of values in data file for discount codes. In Indexed Dataset parameters multiple parameter names can be defined separated by “,”. 

Steps to Add Indexed Dataset Parameter

Go to Parameter Settings menu > Add Parameters > Indexed Dataset Parameter. The Add Indexed Dataset Parameter window is displayed.

Figure 72: Add Index Dataset Parameter

Following are the properties of Indexed Dataset parameter:

  • Parameter Name(s): This defines the parameter which is used as index from the available parameters.
  • Header Line Number: In some situations, consider first few lines as headers. System does not consider these lines as data lines while picking data from file. By default, header line is 0.
  • Column Delimiter: This defines the column delimiter of the file. The data will be spitted according to this delimiter. By default, column delimiter is ‘,’. User can use special symbols as column delimiter.
  • First Data Line: In some situations, user might want to start reading data from a particular line number. So, they can use this field to indicate which line it should consider as first Data Line. By default, first Data Line is 1.
  • Fetch Parameters from Header: It is to get the parameter names from header line of the file. Example: If the header line is Name, AccountNo, CreditCardNo, Balance and the column delimiter is “,” then the parameters names is Name, AccountNo, CreditCardNo and Balance.
  • Index Dataset File Name: This defines the file name from where the values need to be taken. Data file should have index parameter as the first field.
  • View: Click to view the Indexed Dataset File name
  • Choose: Click this button to choose the Indexed dataset file from a local directory.
  • Import: In Import from database, the user has the following fields:
Figure 73: Import From Database

Fill in the following fields to import:

  • Database Type: Select the database type to be imported.
  • URL Prefix: Enter the prefix to be entered before the URL.
  • URL: From where the database is to be imported.
  • User ID: Enter the User ID of the database.
  • Password: It is the password of the user.
  • Query: In this field, the user has to provide the query of importing the data from the Database.
    • Index Dataset Contents: Contents can be any combination of characters, numbers, special characters are also allowed. These contents can be loaded from an existing file from the server by specifying Dataset File name and clicking on View. User can also enter data in this field and upload it using Upload
    • Table Format: By applying this checkbox, Index dataset content can be viewed in table format.

Advanced Settings

  • Ignore Invalid Data Lines: Selecting this check box provides user the flexibility to ignore the invalid lines present in the file or to have an error in case of invalid line.
  • Default values if index parameter value is not found: If no value matches in file regarding the index value comes in request then the default value serves for index parameter.
  • Parameter fields whose value is from file: This option is used if user want to refer to contents of some other file for a particular column. Here user can tell which column means it is data and which column means a file path. The user has to enter the field numbers along with value or file. For example: If Field1 is value and Field2 is file, then enter F1=value; F2=file.

Example:

 If indexed dataset contents are

001/home/Service Virtualization/user1,LA

002/home/Service Virtualization/user2,CA

003/home/Service Virtualization/user3,NY

In parameter value, user provides F1=file, and F2=value it means the first parameter value comes from the file path which is specified in content and the second parameter value is itself. (LA/CA/NY).

Figure 74: Advanced Settings(Index Dataset)

Note: A user cannot save a blank file or provide blank dataset contents. While doing so, an error message “Please enter dataset content” is displayed.

Date/Time Parameter

Date/Time replaces the parameter with the current date and/or time. To specify a date/time format, user can select a format from the format list or specify his/her format.

Steps to Add Date/Time Parameter

Go to Parameters Settings menu > Add Parameter > Date Time Parameter. The Add Date/Time Parameter window is displayed.

Figure 75: Date/Time Parameter

Following are the properties of Date/Time parameter:

  • Parameter Name: This value must begin with a character. Numbers or underscores can be used for the rest of the name. Max length can be 64 characters.
  • Format: Defines the format of date/time by selecting one from the available list of formats.
  • Sample (Current Date/Time): Displays the current date and time of the system in the selected format.
  • Offset: Offset in days from current day. It can be 0, a positive number, or a negative number. If its value is positive, then it adds the number of days to the current day and uses that date. If the offset is negative, then the value of the parameter is offset several days before the current date.
  • Update Value On: This property has two options:
  • SESSION – Value of the parameter is initialized only once during a session at the time of first use and is not changed during the session. This means the parameter is set once for each service request. It does not depend on how many times this parameter is used in response template.
  • USE – Value of the parameter is set every time it is used in the response template.

Random Number Parameter

Random Number replaces the parameter with a random number. User can set a range of numbers by specifying minimum and maximum values. They can use the Random Number parameter type to sample the system’s behavior within a possible range of values.

Steps to Add Random Number Parameter

Go to Parameters Settings menu > Add Parameter > Random Number Parameter. The Add Random Number Parameter window is displayed.

Figure 76: Random Number Parameter

Following are the properties of random number parameter:

  • Parameter Name: Its value should be started with a character. Further number, underscore can also be used. Max length should be of 64 characters.
  • Minimum: It is the minimum number of digits used for range, should be a number only. There is no limit to a minimum number of digits.
  • Maximum: The maximum number of digits used for range. No limit to maximum number of digits.
  • Format: Select a number format, indicating the length of the random number. Specify (%01lu or %lu) for one digit, %02lu for two digits, and so on.
  • Update Value On: This property has two options:
  • Session – Value of the variable is initialized only once during a session at the time of first use & is not changed during the session. Means the parameter is set once for each service request. It does not depend on how many times this parameter is used in response template.
  • Use – Value of the parameter is set every time it is used in the response template.

Random String Parameter

Random String replaces the parameter with a random string. User can set a range for number of characters in a string by specifying minimum and maximum values. They can use the Random String parameter type to sample the system’s behavior within a possible range of values.

Steps to Add Random String Parameter

Go to Parameters Settings menu > Add Parameter > Random String Parameter. The Add Random String Parameter window is displayed.  

Figure 77: Random String Parameter

Following are the properties of random String parameter:

  • Parameter Name: It defines the name of the parameter. User can use the Random String parameter type to sample the system’s behavior within a possible range of values.
  • Minimum: It defines the minimum number of characters used in Random String. Default value is 0.
  • Maximum: It defines the maximum number of characters used in Random String.
  • Character Set: Define characters to be used in Random String. Characters can be defined either individually i.e. age or range i.e. A-Z. Accepted character set are (a-z, A-Z, 0-9)
  • Update Value On: This property has two options:
  • Session – Value of the variable is initialized only once during a session at the time of first use & is not changed during the session. Means the parameter is set once for each service request. It does not depend on how many times this parameter is used in response template.
  • Use – Value of the parameter is set every time it is used in the response template.

Unique Number Parameter

A unique number parameter generates a unique value from the specified range. This is helpful in case where unique data is required e.g. execute a query for all customer ID, whose IDs number ranges from 100 to 999, create 900 Vusers and set the start number to 100 and block size to 100.

Steps to Add Unique Number Parameter

Go to Parameters Settings menu > Add Parameters > Unique Number Parameter. The Add Unique Number Parameter window is displayed.

Figure 78: Add Unique Number Parameter

Following are the properties of random String parameter:

  • Parameter Name: Unique name of the parameter.
  • Format: It is used to define the format of a unique number to be generated. There are the following formats used:
  • %01lu
  • %02lu
  • %03lu
  • %04lu
  • %05lu
  • %06lu
  • %07lu
  • %08lu
  • %09lu
  • Update Value On: This property has two options:
  • Session – Value of the variable is initialized only once during a session at the time of first use & is not changed during the session. Means the parameter is set once for each service request. It does not depend on how many times this parameter is used in response template.
  • Use – Value of the parameter is set every time it is used in the response template.

 

Cookie Parameter

Cookie parameters are used to hold the values for composing service responses. The values for a cookie parameter can be assigned from the cookie coming in the request.

Steps to Add Cookie Parameter

Go to Parameters Settings menu > Add Parameters > Cookie Parameter. The Add Cookie Parameter window is displayed.

Figure 79: Add Cookie Parameter

Following are the properties of Cookie parameter:

  • Cookie Name: Cookie name for which the parameter is defined. It is optional. If not passed, then the cookie name is the same as the cookie parameter name. More than one parameter can be defined for one cookie. This has meaning if the user needs to apply different save offset, transformation, etc. to get different values in different parameters.
  • Parameter Name: Name of parameter to be associated with a cookie. This name must be unique among all parameters in the service. Example: “JSessionIdVar“.
  • Start Offset: This is required if only part of the cookie value needs to be assigned to the parameter. The offset value must be non-negative. Only numbers are allowed and there is no limit. It defines the starting position of the portion which needs to be extracted means from where value of variable is started. Offset can have any value >= 0;

0 indicates save from the beginning of the value. (Default)

       > 0 indicates save after this offset (Offset 0 mean 1st character)

It is enabled when From Beginning check box is disabled. If the Start Offset value is set to 5 then it truncates the first 5 characters and saves this altered data, starting from the 6th position to the last position, in the searched parameter variable. Save Offset value can lie in the range 0-100 (inclusive of boundaries). User can also specify whether to consider a complete length or a specified length.

  • Maximum Length: Maximum length of the cookie value to be saved. A default value for the variable is 0.If the value is 0, then save complete cookie value.

Note: User will also get the option to select the checkbox, if they want the maximum length to be till the end.

  • Decode Cookie value: To decode when the cookie value is extracted from the HTTP request. Decoding is done for the URL style encoded value of the cookie. Value is not case sensitive.
    • Decode – value is decoded before saving in the parameter.
  • Do not decode – not decoded
  • Transform: Specifies any built-in transforms, which need to be applied to the cookie value before it is assigned to the parameter. This is done after Decode if decoding is to be done.
  • Reverse: If user uses reverse, then string fetched from request is reversed in the response file.
  • None: No transformation is done. It displays the string as it is without any modification.
  • Encode in response template: To encode cookie parameter if used in the response template. Value is not case sensitive.
  • None – No need to encode the value in response template.
  • All – Encode all character of value in response template.
  • Specified – Encode only specified characters of value as defined by the SpecifiedChars argument. Special characters to be encoded.
  • Action On Not Found: The action to be taken if cookie name is not found in the HTTP request. No cookie value can be empty.
  • Do not log message – Do not log message.
  • Log message: Log message (Message is logged in the error log).
  • Default Value: Default value of cookie parameter if the cookie is not found in the request. It can be empty. By default, it is empty.

 

 

XML Parameter

XML variables are initialized as a result of searching a request for user specified criteria. Any pattern appearing with in the XML node would be used to initialize the value of XML variable.

Steps to Add XML Parameter

Go to Parameters Settings menu > Add Parameter > XML Parameter. The Add XML Parameter window is displayed.

Figure 80: Add XML Parameter

Following are the properties of XML parameter:

  • Parameter name: This is the name of XML variable being defined. It’s a mandatory field. This name must be unique among all parameters in the service. It must start with an alphabet and after alphabet, user can use numbers and underscore also. Maximum length should be of 64 characters.
  • XML Node Path: Specify the full path of the node for which the user needs to fetch the value. For example, in the below XML, the user needs to get the value of node referringId then XML Node Path should be as follows:

<soapenv:Envelope>
<soapenv:Body><prepareOrder><in ><header><referringId>. Complete path of any node can be set using “Set XML Node Path” button that is explained below.
<soapenv:Envelope xmlns:soapenv=”http:////schemas.xmlsoap.org/soap/envelope/”>
  <soapenv:Body>
    <prepareOrder xmlns=”http://www.mst.macys.com/xsd/order”>
      <in>
         <header xmlns=””>
            <referringId>271</referringId>
            <partnerOrderId>2159013153</partnerOrderId>
         </header>
      </in>
    </prepareOrder>
  </soapenv:Body>
</soapenv:Envelope>

 

  • Occurrence Count: It is required if multiple occurrence found of a specified node. User has three options for this.
  • Index: By selecting this user can define which index of occurrence needs to pick.
  • All: If user selects this option then system takes all occurrence of the specified node.
  • Any: It takes randomly any one occurrence out of all.
  • Conversion: This option is used to encode search patterns. It has following options.
  • None: In this option, no encoding is applied.
  • HTMLToURL: It converts HTML-encoded data to a URL-encoded data.
  • Value Type: It specifies that the value of parameter is node value or attribute value. It has two options.
  • Node Value: In this options system gets the value of the node. For   example if XML Node Path is

<soapenv:Envelope><soapenv:Body>
<in><header><referringId> with ‘Node Value’ option then it gets the value 271.

  • Attribute Value: In this option, system asks for the attribute name and get the value of specified attribute. For example, if XML Node Path is <soapenv: Envelope><soapenv: Body><prepareOrder> with the ‘Attribute Value’ option and the Attribute name is ‘xmlns’ then it gets the value “http://www.mst.abc.com/xsd/order”.
  • Character(s) in the beginning of request are not part of XML: This option is used to provide the number of characters that is not a part of xml request and are coming at the beginning of request.
  • Character(s) at end of request are not part of XML: This option is used to provide characters that are not a part of xml request and are coming at the end of request.
  • Node selection criteria (Where Clause): Argument specifies the qualifiers/clauses. These are particularly useful when NODE occurs multiple times but may also be used to make sure that Node value is assigned only when a certain condition is matched. When multiple WHERE arguments are present, all WHERE qualifiers/clauses should be satisfied WHERE argument has the form WHERE=type=value.

Two options are applicable for where clause

  • None: Nothing to node selection criteria.
  • Specified: Type can take the following forms:

Node value like Natraj i.e.: WHERE=<>=”Natraj” Attribute, attribute name in angular braces specify the attribute value. Value should be specified in double quotes. If the values contain a double quote (“).

  • Sample Request for Template Name: Here user can view the sample request contents of any template by selecting a dropdown. We are displaying the sample request here to help the user to specify the node/attribute.
  • Set XML Node Path: This button is to help user to get the complete path of the node and set in to XML Node Path by selecting any node. For example if user selects ‘partnerOrderId’ node and clicks on this button then complete path of this node ‘<soapenv:Envelope><soapenv:Body><prepareOrder><in><header>
    <referringId>’ is automatically set to XML Node Path.
  • Set Attribute Name: This button is to set the attribute name by selecting it in the sample request content.
  • Auto Wrap: It wraps the sample request data of template automatically. This feature is used for formatting purpose only.
  • Beautify: It is used for formatting or beautifying the sample requests and response templates in a well-structured format.

JSON Parameter

JSON variables are initialized as a result of searching a request for user specified criteria. Any pattern appearing within the JSON node would be used to initialize the value of the JSON NO variable.

Steps to Add JSON Parameter:

Click Parameter Settings > Add Parameters > Json Parameter. The Add Json Parameter window is displayed.

Figure 82: Add Json Parameter
Figure 83: Sample Request

Following are the properties of JSON parameter:

  • Parameter name: Parameter name is the name of JSON variable being defined. It’s a mandatory field. This name must be unique among all parameters in the service. It must start with an alphabet and after alphabet, user can use number and underscore. Maximum length should be of 64 characters.
  • Object Path: Specify the full path of the node for which the user needs to fetch the value. For example, in below JSON, user needs to get the value of node email then JSON Node Path should be “root.email”.

Note: JSON path should start with “root.”.

Request of JSON: –

“expand”: “attributes”,

“link”: {

“rel”: “self”,

“href”: “http://localhost:8095/crowd/rest/usermanagement/1/user?username=my_username”

},

“name”: “my_username”,

“first-name”: “My”,

“last-name”: “Username”,

“display-name”: “My Username”,

“email”: “user@example.test”,

“password”: {

“link”: {

“rel”: “edit”,

“href”: “http://localhost:8095/crowd/rest/usermanagement/1/user/password?username=my_username”

}

},

“active”: true,

“attributes”: {

“link”: {

“rel”: “self”,

“href”: “http://localhost:8095/crowd/rest/usermanagement/1/user/attribute?username=my_username”

},

“attributes”: []

}

  • Occurrence Count: It is required if multiple occurrence found of specified node. User has three options for this.
  • Index: By selecting this user can define which index of occurrence need to pick.
  • All: If user selects this option then system takes all occurrence of the specified node.
  • Any: It takes randomly any one occurrence out of all.
  • Start Offset: This option is used to indicate the starting of the offset. By default, it is set to 0.

Note: If the user wants the set the offset to be set from the beginning, then the user has to click on the From the Beginning checkbox.

  • Maximum Length: This option is used to indicate the maximum length of the offset. By default, it is set to 0.

Note: If the user wants the maximum length to be the end, then they have to click on the Till the End checkbox.

  • Conversion: This option is used to encode search pattern. It has three options.
  • None: In this option, no encoding is applied.
  • HTMLToURL: It converts HTML-encoded data to a URL-encoded data.
  • HTMLToText: It converts HTML-encoded data to plain text format.
  • TextToUrl: It converts TEXT-encoded data to URL format.
  • UrlToText: It converts URL-encoded data to plain text format.
  • UrlToHtml: It converts URL-encoded data to HTML text format.
  • TextToHtml: It converts Text data to HTML text format.
  • TextToBase64: It converts Text data to Base64 format.
  • Base64ToText: It converts Base64 data to Text format.
  • Encoding Options: Encoding is used to encode special characters to their ASCII Users can encode any number of special characters i.e. all, specific, or none. User can have the following options:
  • Encode all special characters except (+), (-), (.), (_): All special symbols except + -. _ are encoded. It is the default value.
  • Encode only specified characters: The user can specify which special characters to encode in Characters to encode
  • Do not encode special characters: None of the special characters is encoded. However, space is encoded always.
  • Character to Encode: This option will be enabled in case of Encode Only Specified Character option. In this field, the user has to provide the character to be encoded.
  • Encode Space by: This option specifies to Service Virtualization how to encode Space. User can have two options: ‘+’ or ‘%20’. If ‘+’ is chosen, Service Virtualization encodes Space by ‘+’ and if ‘%20’ is chosen, Service Virtualization encodes Space by ‘%20’. The default value is ‘+’.
  • Sample Request for Template Name: Here user can view sample request contents of any template by selecting in to a dropdown. We are displaying the sample request here to help user to specify the node/attribute.
  • Set JSON Node Path: This button is to help user to get the complete path of the node and set in to Object Path by selecting any node.
  • Beautify: It is used for formatting or beautifying the sample requests and response templates in a well-structured format.

Service Settings

HTTP Headers

An HTTP header is a field of an HTTP request or response that passes additional context and metadata about the request and response. Service Virtualization sends following headers in the service response:

  • Content-Length
  • Content-Type – If content type was selected 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.

Steps to add HTTP headers

To access this option click on  the Service Settings  icon and select HTTP Headers as shown in the below figure.

Figure 84: HTTP Headers Option

Once user clicks the option, they have the window as per the below picture.

Figure 85: HTTP Headers

Note:

  • ‘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.)
  • Template based ‘Content type header’ has higher priority than Service based ‘Content type header’.
  1. Enter the header name and press enter
Figure 86: Add Header

2. Click Add button to add headers.

HTTP Settings

HTTP Settings allows user to use HTTP settings, such as keep alive time and decode request content settings. It also a provides provision to configure mock response details, content length indicator, and date header. To access this option click on  the Service Settings  icon and select HTTP Settings as shown in below figure.

Figure 87: HTTP Settings

Following are the fields in HTTP Settings:

  • Decode Payload Content: HTTP settings have decoded request content and keep alive timeout, decode content settings is useful if the request is coming in encoded format (URL encoded). If decoding is enabled, request is decoded so that request parameter value is populated with the decoded value (not the encoded one). In addition, user can use decoded value in Prefix and Suffix in the Request parameter definition. If a user wants to decode the payload content, they can choose Yes from the drop-down provided, else the user can choose No in case they do not want to decode the payload content. If option “No” is selected, then the system will not decode the request contents.
  • Keep Alive Timeout: Keep Alive timeout is useful when the user needs to use connection timeout for service. The keep alive timeout is defined in seconds. Default HPD Keep Alive Connection Timeout is 450 secs.
  • Compressor Type: This is to enable the different types of ‘Content-Encoding’ header in http response like gzip, deflate, and Br. The response will also be compressed.
    • None: No Compression
    • Gzip or Deflate: Gzip (or Deflate) compresses the web pages and CSS files before sending them to the browser. This operation drastically reduces transfer time since the files are much smaller. In terms of cost versus benefit, gzip compression should be near the top of your page speed optimizations if you don’t have it setup already. Gzip is actually a very simple idea that has extreme power (when put to good use of course). Gzip locates similar strings within a text file (in our case this is commonly CSS and HTML codes) and replaces those strings temporarily with some placeholders to make the overall file size smaller.
    • BR: Brotli compression ensures better space utilization and faster page loads with smaller compressed size and it is far better than gzip compression mechanism.  While Gzip compression uses a fixed window of 32KB but Brotli uses a sliding window of 1KB to 16MB. In NetOcean, Brotli technique is applicable for Correlated Services as well as Static Services.
  • Mock Response Details: In the mock response section, the user can configure the percentage of the selected HTTP Status code to be reflected in the response of the service.
Figure 88: Mock Response Details
  • Content Length Indicator: Content Length Indicator allows the transfer of data into a series of overlapping chunks. Once the user selects the Enable Content Length Indicator check box, more options are displayed in the below format.
Figure 89: Content Length Indicator

User can choose from two options in the Chunk Scheme drop-down: Size of chunk and Number of chunks. For details refer to Template based Content Length Indicator.

The check box for Default size of chunk/Default number of chunks is selected by default. User must clear the check box to enter a value other than the default value.

Date Header: Date header is used to display the current date and time in the response template. Once the user enables this check box, the current date and time is appended in the response.

Figure 90: Data Header

Service Time Delay

Service Virtualization sends a response of the service as soon as the request is received. So, there is no delay in the Response. Users can add service time delay by using Service Time Delay settings.

To access this option click on the Service Settings icon and select Service Time Delay as shown in the below figure.

Figure 91: Service Time Delay Option

Once the above option is selected, a new window opens as shown in figure below.

Figure 92: Service Time Delay Open API

Service time delay settings have the following fields:

  • Overwrite Global Service Time Delay: Select this check box to enable service time and proceed further. In overwriting global service time delay, there are the following two options:
    • No service timeNo service time used.
    • Exponential Random service time with median of: For exponential random distribution, the median is roughly around ¼th of the mean. The service time is taken in milliseconds (ms).
    • Constant service timeThis property is used to provide constant service time. The constant service time is taken in milliseconds (ms).
    • Random (Uniform distribution) service timeThis property is used for uniform distributions service time. The random service time is taken in milliseconds (ms).

Trace Level

Service Virtualization logs important messages which are called traces. A trace level is used to determine which events the trace provider generates. To access the Trace level, click on  the Service Settings  icon and select Trace Level as shown in below figure.

Figure 93: Trace Level Option

Once user clicks the option, the below figure appears.

Figure 94: Trace Level Open API
  • Disabled: This option is used to disable the trace level. If a user selects this option, then there will be No logs.
  • Log URL and Parameter: This option is used to log a request URL with parameter details like parameter name and its value.
  • Log URL, Parameter, and Request/Response: This option will log request URL with parameter details like: parameter name and its value, Request/response.

Comments

Using Comments, the user can add comments to the service for his/her reference. For example, design notes, modifications – any user-defined comments.

To access the Trace level, click on  the Service Settings  icon and select Comments as shown in below figure.

Figure 95: Comments Option

Once user click the option, following page appears.

Figure 96: Comments

Call back

User can use Service Callbacks to add their own custom scripts using C language based callback methods. To access the Trace level, click on  the Service Settings  icon and select Callback as shown in below figure.

Figure 97: Call Back option
Figure 98: Call Back Fields

 There are two types of callbacks:

  • Use On Request Method: This method is called on receiving the service request and after all search and conditional parameters are processed and before applying service delay time.
  • Use After Request Method: This method is called just before sending the response of the service.

Note: If a user wants to use their own library, then they have to click on the Use External Library checkbox in order to upload their own library and then click on the Add Upload Library  button to choose their library file. the files can either be selected from the drop-down list or the user can upload them from their system.

Add API

An API is a software interface that allows two applications to interact with each other without any user intervention. To access this, click on the Add API button on the top right corner.

Figure 99: API Fields

On add API, there are following options available which the user has to select to add an API:

  • Group: In the group, the user can select on which group the API is to be added. There are following three options which a user can select from the drop-down as follows:
  • All: On selecting this option, the selected API will be added on the callbacks.
  • Database: On selecting this option, the selected API will be added on all the Database groups.
  • Utility: On selecting this option, the selected API will be added on the Utility groups.
  • Sub-Group: In the sub-group, the user can select on which sub-groups the API is to be added. There are following three options which a user can select from the drop-down as follows:
  • All: On selecting this option, the selected API will be added on all the sub-groups.
  • ODBC: On selecting this option, the selected API will be added only on ODBC groups.
  • String: On selecting this option, the user has to select the Source and the Destination of the string which is to be added.
  • API: In this option, the user can select which API they want to pass for a particular Group and Sub-Group.
  • Destination: In this field, the user has to enter the destination on which the API is to be added.
  • Source: In this field, the user has to enter the source from where the API is to be added.

Note: In case the source name is a program variable, then the user needs to select the If Source Name is a Program Variable checkbox.

  • Length: In this option, the user has to enter the variable length.
  • Return Variable: In this option, the user has to enter the return variable.
  • Connection String: In this option, the user has to provide the connection string’s name on which the information is stored.

API Details

  • In API Details, the user can see all the details which are being entered by them such as: Syntax, Description etc.
  • In API details, the user can see the information for the following:
  • Syntax: It will show the syntax of the API.
  • Description: It will show the description of the syntax.
  • Example: This field will show the example for the syntax.
  • Parameterization: This field is used to parameterize the arguments which are passed in the function.
  • Return: It will show the type of the variable which will be returned.

Note: The return variable and connection string is only applicable in case if the user selects Database in Group field and ODBC in Sub-Group field. Once the user has entered the values on all the fields, the user can add the values on clicking the ADD  button or can click on the Cancel  button to cancel the entries. Once all the values have been entered by the user and also the API is being added, the user have to click on the Save  button in order to save the call back details.

Following is the template of On Request callback method user can use:

#include <stdio.h>

#include <time.h>

#include <stdlib.h>

#include <string.h>

#include “/var/www/Service Virtualization Server/include/Service Virtualization Server_log.h”

#include “/var/www/Service Virtualization Server/include/Service Virtualization Server_string_api.h”

#include <errno.h>

#include <unistd.h>

 

/*——————————————-

  Name: MyService_on_request_callback

  Purpose: This method is called on receiving the service request and after all search and conditional parameters are processed and before applying service delay time.

  Input:   None

  Return:  The function controls service time. Return values can be:

           0 – No service delay time. Override service delay time configure if any

          -1 – Use service delay time as configured

          >0 – Use service delay time in mili-seconds returned by this method

 ————————————————*/

int MyService_on_request_callback()

{

   return –

 

Forward Settings

For forward settings details refer to Forward.

Figure 100: Forward Settings 

Recording a Service

Here, we have mentioned the pre-requisites and steps for recording a new service.

Prerequisites

  • Web service is an existing service and is available for recording.
  • Application is configured to interact with back-end services at the controller service endpoint IP address and the port to be used for recording.
  • There are no firewall restrictions between the Application and Controller and Controller and Backend servers to be used for recording.
  • There are no other processes in the appliance using the IP/port to be used by the recorder.

Following diagram displays the setup for recording a service:

  • Service Virtualization Recorder: Process by which requests and responses are recorded.
  • Service Repository: It is a directory or repository, which contains all the virtualized services.

Recording Configurations

Before recording a service, the user needs to perform some configurations based on the recording mode. Follow the below-mentioned steps for recording configurations:

  1. On the Services menu, click the Record Services menu item.
Figure 103: Record Service Option

2. The Service Recording window is displayed with the following recording modes – HTTP Recording, JDBC Recording, and Socket Recording as shown in the below figure.

Figure 104: Service Recording

Note: When the user tries to record a service/page, and if the recorder is already running in the background, a pop up dialog box with a message is displayed – “Recorder is already running. Do you want to stop the recorder and start recording?”. You can stop the recorder from there and start a new recording.

In the subsequent sections, the recording configurations of each recording mode are described. Let’s start with HTTP Recording first.

HTTP Recording Configurations

In the Recording Type section, there are two options for recording: Web Service Recording and Web Page Recording.

  1. Web Service Recording Configurations

For Web Service Recording in HTTP configuration, first, select HTTP Recording from the Recording Mode drop-down as shown in Figure 101. After that from the Recording type drop-down select Web Service Recording as shown in the figure below.

Figure 105: HTTP Recording Configuration

Provide the following details in the fields for configuration:

  • Name: Name of the recording for reference purposes. User is required to provide the recording name that works as a prefix while creating a service through recording.

Example: Recorded Service name: ‘shoppingCart’

Prefix by user: ‘cavisson_’

Service name added in a record: ‘cavisson_shoppingCart’

  • Port: Port on which incoming request comes. Here, a dropdown list is provided for the recording port. User may provide either their recording port or select some port from the provided dropdown list.
  • Request URL Filter: This is used to specify the URL filter if the user needs to send different URLs on the same recorder port to different backend servers. In most cases, it is * to indicate all URLs.
  • Protocol: This is used to specify the protocol of recording whether it is HTTP or HTTPS.
  • Service Endpoint hostname/IP: Hostname or IP address of the backend server or endpoint server. It is the server from where the response is captured to Service Virtualization.
  • Service Endpoint Port: Port number of the backend server port on which the application is running.
  • Client Certificate: A Client certificate is a variant of a digital certificate that is widely used by the client to make the systems authenticated so that trusted requests should go to a remote server. This certificate plays a crucial role in several joined authentication designs, which offer a well-built guarantee of a requester’s identity.
  • Endpoint Certificate: Endpoint certificates are very small data files that digitally combine or join a cryptographic key to the company’s details and information. When SSL is installed on a web server, it triggers the security device and the https protocol (over port 443) allowing locked and safe connections from a web server to a browser.
  • Action: Action column gives the user the option to add the service for which the details have been provided.

Note: At the time of service recording, the user can use all the special characters (in service endpoint hostname) except Hash (#) and space as these are a special type of characters used in URI and they can only be read by the client (browser). The server cannot use # in URI.

 

2. Web Page Recording Configurations

For Web Page Recording in HTTP configuration, first select HTTP Recording from the Recording Mode drop down as shown in Figure 101. After that from the Recording type drop down select Web Page Recording as shown in the figure below.

Figure 106: Web Page Recording

Provide the following details in the fields for configuration:

  • Name: Name of the recording for reference purposes.
  • Port: Port on which incoming request comes. Here, a dropdown list is provided for the recording port. User may provide either their recording port or select some port from the provided dropdown list.
  • Request URL Filter: This is used to specify the URL filter if the user needs to send different URLs on the same recorder port to different backend servers. In most cases, it is * to indicate all URLs.
  • Action: Action column gives the option to add the service for which the details have been provided.

JDBC Recording Configurations

Java Database Connectivity (JDBC) is an application-programming interface (API) for the programming language Java, which defines how a client may access a database. It is a Java-based data access technology used for Java database connectivity. User can perform JDBC recording and can virtualize the database services.

To access JDBC Recording Configuration select JDBC Recording from the Recording Mode drop down as shown in Figure 101. On selection, the JDBC Configuration option opens as shown in the below figure.

Figure 107: JDBC Configuration

Provide the following details for the JDBC Configuration:

  • Connection ID: Select the Database Name.
  • JDBC Driver: It is a software component enabling a Java application to interact with a database.
  • Connection String: Enter the IP/Port.
  • Login Credentials: Enter the Username and Password.

Socket Recording Configurations

User can record the generic data coming on the TCP socket as configured and send it to the server. To record generic TCP services in Service Virtualization, a recorder is created which acts as a proxy.

To access Socket Recording Configuration, select Socket Recording from the Recording Mode drop down as shown in Figure 101. Enter On selection, Socket Configuration option opens as shown in the below figure.

Figure 108: Socket Configuration

Provide the following details:

  • Name: Provide the recording name. It is used to provide the prefix for the service name. It has the same functionality as in the previous recordings. Example: If the user provides any Recording Name Demo, all the service name concerning this configuration is saved as Demo_ServiceName.
  • Port: The port on which the user wants to record. This displays the list of the defined port range. User can select any port from the list, or mention any port manually that any other processes are not using.
  • Protocol: Select the protocol from the list. It can be either SSL (secure) or NON-SSL (non-secure).

Note: User can enter a custom port while creating recorded services. If the user keeps it blank, the default endpoint port is fetched. Default SSL port is 443 and the Non-SSL port is 80.

  • Service Endpoint Hostname/IP: Configure the service endpoint hostname and IP.
  • Service Endpoint Port: Enter the Service Endpoint Port. For now, the SSL port is 443 and Non SSL port is 80, but the user can specify this port according to configuration.

SSL Settings: This option is enabled only the if user selects the SSL protocol. Users can upload the certificate (client certificate and endpoint certificate) by clicking the  button.

Figure 109: SSL Setting
Figure 110: Upload Certificate

Advanced Settings: User can configure the advanced settings for the TCP. The advance settings can be done for request and response both. On clicking the  button, the Advance Settings window is displayed.

Figure 111: Advance Settings

Message Boundary Policy

Message Boundary Policy tells the recorder when to consider the end of the message. Let’s understand them in detail.

  1. Messages are of fixed length of bytes: End of the message is considered at specified bytes so data reading is done till specified bytes.
  2. Messages are delimited by specified character: End of the message is considered when the recorder finds the specified delaminate. A specific character or sequence of characters, such as a pipe or comma, indicates the end of the message. The entire sequence must be matched. The delimiter itself is not included in the message. Following conditions must be kept in mind:
  • Reading of data is stopped if a suffix message is found.
  • Max Delimiter length can be 64 bytes.
  1. Messages are delimited by end-of-data (complete TCP segment): End of the message is considered after reading a single segment.
  2. Messages are complete if any part of the message contains specified characters: End of the message is considered when a specified character is found.
  3. Messages are prefixed by message length in format of byte: End of the message is considered as per the specified prefix length. Prefix type can be text or binary. For text type, the prefix length can be 1 to 9 bytes while for binary type, the prefix length can be 1,2,4,8 bytes.
  4. Messages are complete after connection is closed: End of the message is considered at the connection to close so data reading is stopped as the connection gets closed.
  5. Message is complete after idle timeout is reached: End of the message is considered when timeout is reached. It does not apply to the UDP protocol.

Message Format

It has the following decode types

  • Plain text
  • Binary to Hexadecimal
Figure 112: Message Format

Note:

  • The policy and timeout settings are available for both request and response. To have the same policy and settings at the response end, select the Same As Request check box.
  • Once Users are done with advanced settings, they can save this configuration in UI. This is displayed in tabular format.
  • User can provide multiple configurations for different recording name, host name, and port as shown in the below figure.
Figure 113: Multiple Configuration

Timeout Settings (ms)

Provide the values for the following timeout options as shown in Figure 111 :

  • First Byte Receive Timeout
    • It waits for the first request.
    • Connection is closed if this timeout occurs.
  • Idle Timeout
    • It is a delay between two conjugative reads. 
    • It resets on every read. 
    • Connection is closed if end policy is not timeout and timeout occurs else process data and start reading again.
  • Max Receive Timeout
    • It is max read timeout.
    • It resets on every read.
    • Connection is closed if end policy is not timeout and timeout occurs else process data and start reading again.
Figure 114: Timeout Settings

Http Recording

Web Service Recording

Let’s take an example of Web service recording where the recording mode is HTTP Recording.

  1. Select the Web Service Recording option from the Recording Type drop down.
Figure 115: Web Service Recording Option

2. Provide the required details in the fields, such as recording name, recording port, protocols, service endpoint hostname/IP, service endpoint port, client certificate (optional), and endpoint certificate (option), and click Add. (For details of the fields, refer to HTTP Recording Configurations in the above section)

3. Click the Start Recording button to start the recording. A pop up message as shown in the below figure for successful recording starts appears at the top of the page.

Figure 116: Start Recording Message

4. Click OK. The following window is displayed where recorded requests and response requests are displayed as ‘0’ initially.

Figure 117: Start Recording Message

5. Open the URL in the browser, which is mentioned in the recording screen.

6. Browse web application for example: www.google.com, and wait until the page is fully loaded. Navigate a few pages there.

7. Once the requests and responses are captured, their count is displayed accordingly along with the details of captured URLs their request payload, and response payload as shown in the below figure.

Figure 118: Request Response Count

8. To stop recording the service, come back to the Service Recording window and click the Stop Recording

9. After the user clicks the Stop Recording button, Request and Response of every URL are displayed as in the snapshot. The service and template names for each URL are assigned automatically, which can also be edited.

Figure 119: Header List

After creating a service through recording, all the respective headers, and status codes are configured in the service level and template level as well. It takes less time to configure all the headers, which are captured through recording.

User can either configure or not configure service time during recording by using the “Enable Service Time” check box.

Figure 120: Enabling Service Time

10. Likewise, requests and responses can be recorded for other URLs too.

11. To create the service, select the check box for the particular URL and click on Create Service(s) or Create Service(s) and Activate

12. If the service already exists, the following window is displayed.

Figure 121: Warning Window

For any service, which is already simulated in the server, users can create services according to their needs after recording the application URL. This avoids the addition of templates into existing services with the same URL.

Options available:

  1. Create the template in the Existing Services.
  2. Delete the Existing Services and create new Recorded Services.
  • Disable the Existing Services and create new Recorded Services.
  1. Create Backup (Disabled Mode) and Delete Existing Services and create new Recorded Services.
    1. Once, the user clicks the Create Service(s) button, the service gets added and is displayed in the list of services.

 

 

Web Page Recording

  1. Select the Web Page Recording option from the Recording Type drop down.
  2. Provide the required details, such as the recording name, recording port and click Add. For details on these fields refer to HTTP Recording Configurations in the above section.
  3. Click the Start Recording button to start the recording.
Figure 122: Start Recording

4. Import the certificate file. (Get it from your Cavisson representative).

5. Open browser and enable the proxy. Use the IP and port for proxy servers for all protocols as mentioned in the below window.

6. Browse the application and wait until the page is fully loaded.

7. The captured request and response count is displayed along with captured URLs, request payload, and response payload.

Figure 123: Recording Status Page

8. After the user click the Stop Recording button, the Request and Response of every URL are displayed as in the snapshot. The service and template names for each URL are assigned automatically, which can also be edited.

Figure 124: Header List

After creating a service through recording, all the respective headers and status code are configured in the service level and template level as well. It takes less time to configure all the headers, which are captured through recording.

User can either configure or Not-Configure service-time during recording by using the “Enable Service Time” check box.

9. To create the service, select the check box for the particular URL and click on Create Service(s) or Create Service(s) and Activate

Figure 125: Capture Host Info

10. Click Proceed. The captured web page recording is displayed on the Manage Services

Figure 126:Manage Service Window

Note: ‘Host’ column displays the hostname mentioned at the time of recording.

JDBC Recording

  1. Once the JDBC recording configurations are done, click the Start Recording Here, the example is for recording a sample application – nsecom.

Note: For the nsecom application URL, kindly connect with the Cavisson representative from the Client Support team.

Figure 127: Recording Configuration

2. In the Browser, provide the host/IP and port and then nsecom.

Example: 10.10.40.18:8003/nsecom

3. Go to Home-Page, then place the order completely for a complete recording.

Page – 1

Page – 2

Page – 3

Page – 4

4. Stop the recording and provide the service name.

Figure 128: Recording Status

5. After the user click the Stop Recording button, the Request and Response of every URL are displayed as in the snapshot. The service and template names for each URL are assigned automatically, which can also be edited.

Figure 129: Request response page

6. Click the ‘Create Service(s)’ button. This creates the service.

Figure 130: Service Page

Socket Recording

Once the configurations are done, click the Start Recording button to start the recording

Figure 131: Recording Status Page

Note:

  • Setup the TCP Client to record the services.
  • UI displays the count for the request and response.
  • The recorded request and response are displayed in the UI.
  • User can see the individual request and response for all recorded requests and responses.

2. Stop Recording: Once the user is done with the recording, stop the recording.

Figure 132: Recording Status Page

3. Captured Request Response List: After stopping the recording, request, and response list is displayed on the UI. All the recorded information is displayed on the UI.

Figure 133: Capture Service List

User can see the following recorded information on UI.

  • Recording name: Recording name is displayed as provided at the configuration time.
  • Port: Port name as configured.
  • Service name: User can see the service name of each recorded request; accordingly, it is displayed on the UI. It is a combination of Recordingname_Socket_port_randomVal.
  • Templates: All the templates are displayed as template1 by default.

4. Create Services: User can create the services for the selected records.

Following conditions are displayed according to the port used in the recording.

If the recorded host is captured on the same port, which is already used by the existing services, then the user needs to select the following option:

  • Create a template in the existing service on the same port.
  • Delete the existing service and create new recorded services.
  • Disable the existing service and create the new recorded services.
  • Take a backup of existing services and create a new service.
Figure 134: Warning Page

5. Create and Activate Services: User can create and activate services.

6. Manage Services: All the services list is displayed on the Manage Services page.

Add Service

User can add a service manually by following four ways:

  • Using User Input
  • Using RR Pairs
  • Using WSDL
  • Using Open API

Adding a Service – Using User Input

A user can create a service here manually. By directly providing the inputs. Using user input, a user can create a service by directly providing the inputs.

  1. On the Services menu, hover over to Add Services menu item as shown in the below figure.
Figure 135: Add Service

2. Now click the ‘Using User Input’ to create the service manually as shown in the below figure.

Figure 136: Using User Input

Service Type – HTTP(s)

Go to the Add Service window and select HTTP(s) in the service type as shown in the below figure.

Figure 137: HTTPs-Service Type

Enter the following fields to add the service as displayed below:

  • Service Type– Select the service type from the drop down.
  • Project: A project in service virtualization refers to a directory that consists of one or more inter-related virtualized services.

User can define various configurations that apply to all the services within that project. Projects provide a way to manage and maintain a cohesive set of virtualized services with a common context or purpose.

  • Subproject: It refers to a smaller unit or subset of services within a project. It allows users to further categorization and organization of virtualized services within the project.
  • Service Name: It is the unique name of the service.
  • URL: Enter the URL of the service.
  • Template Name: Template is the response identification. A service can have multiple templates which can be added once the service is created.
  • Response Content-Type:
  • The content type specifies the media type for the response.
  • Here user can select the content-type for the response from the drop-down list.
  • If no Content-Type is specified, the default is none.
  • Regular Expression: It allows the use of the regular expression in URL so that if some pattern changes in the request and the remaining URL is the same then Service Virtualization responses for this request.
  • Ignore Case: If it is enabled, then the URL becomes case insensitive.
  • Complete Match: It is used to match the complete URL.
  • Protobuf Settings: Here a user can directly upload the protofiles by enabling the checkbox for protobuf, and can provide a name for the protofile.
  • Click the Protobuf Settings This displays the Protobuf Settings window.
Figure 138: Protobuf Settings Window
  • There are two sections: Request and Response. Provide the following details and click Save.
  • Enable Protobuf: Select this check box to enable Protobuf.
  • Upload Proto File: Select the Proto file by using the Choose button or paste the file content in the body section.
    • Request Proto file: To get the content in the encoded format as passed in the request.
    • Response Proto file: To get the response in encoded format from the server.
  • Proto File Name: Provide the name of the proto file.
  • Message Type: This contains the schema of the proto file. This displays the parsed message types from the uploaded proto file. If the content of the proto file is modified, the ‘Message Type’ drop-down is automatically refreshed.

Note: All the fields in the ‘Request’ and ‘Response’ sections are mandatory if enabled.

  • When the user hit a service from Service Virtualization, the data is sent in the encoded format.

If for Response, Content-Type is set to application/x-protobuf or x-application/protobuf then, only response will be converted into protobuf format. Example –

Possible Content-Type header to convert body into protobuf are –

Content-Type: application/x-protobuf

OR

Content-Type: x-application/protobuf

  • Sample Request: Sample request of the service. This is used for testing and for defining Request Parameters. Users can select a file where a sample request is stored by clicking the Choose
  • Response Template: Response of this service for this template. Users can parameterize it later using different types of parameters. They can select a file where a sample response is stored by clicking the Choose
Figure 139: Service Information

3. Click on Add The service is added and the Service Virtualization services window is displayed.

Smart Editor

Service Virtualization has certain text areas where users get long xml, JSON, etc. The content is not formatted in most cases which leads to the need for a Smart Editor which adds color-codes and formatting to the content making it easier to read and analyze.

Features

  • Beautification/formatting of ugly/minified XML, JSON, HTML, CSS, and JavaScript.
  • Addition of color codes in XML, JSON, HTML, CSS, and JavaScript. This feature displays content in different colors according to the category of terms. This feature facilitates writing in a structured language such as markup languages both structures and syntax errors are visually distinct. Highlighting does not affect the meaning of the text itself; it is intended only for human readers.
  • Auto-Closing of tags in XML/HTML when the opening tag is completed with intelligent handling for singular/Unpaired tags.
  • Code-Folding to collapse (hide) and expand parts of a file, making it easier to focus just on the parts of interest.
  • Highlight the matching Tag in XML and HTML that highlights the corresponding matching tag.
  • Highlight matching brackets (like round brackets, square brackets, and box brackets) at the current cursor position.
  • Placeholder display in case of blank content in the editor.

Functionality

  1. To add color-codes to the content, select the specific content type from the drop-down.
Figure 140: Content type

2. After selecting the content type, color-codes is added as follows:

Figure 141: Color Coded Added

 Formatting Content

  1. To format the content for a specific type, select/highlight the content in the editor
Figure 142: Highlighted Content for Formatting

2. Click the beautify icon ( ) to format the contents.

Figure 143: Formatted Content

Generic Socket Type Service

Apart from HTTP(s) service, the user can also virtualize generic socket services. Support is provided for services, which can respond to generic data coming on a TCP socket configured by the user.

  1. Go to the Add Service window and select the Service Type as Generic Socket as shown in the below figure.
Figure 144: Generic Socket
  1. Provide the service information and fill in the following fields:
    • Service Name: Enter the name of the generic socket service.
    • Template Name: Enter the template name.
    • SSL Port(s): Fill in the HTTP port(s).
    • Non-SSL Port(s): Fill in the HTTPs port(s).
  2. Select the sample request, response, and click Add.
  3. The service is added and displayed within the Services section of the Service Virtualization Manage Services window.

Adding a Service with Binary Payload

Users can also upload binary data for request/response payload of HTTP/TCP services in the Add Service window.

  1. Go to the Add Service window.
Figure 145: Add Service Window

2. Fill out the other details of the service to be added.

3. If the file to be used as the payload is a text file (Content type: “text/*” or “application/json”), click the Choose button and select the respective file. In such a case, the contents of a file are displayed on the respective request/response editor so that the user can modify the contents of the editor according to the need.

4. If the payload is a binary, then click on Choose button and upload the file. After upload, the respective request/response editor is set as read-only. Finally, click the Add button to add the service.

Note: The binary and text files are distinguished based on Content-type given by the operating system during upload. Therefore, the files with content-type as “text/*” and “application/json” are only treated as a text files and displayed on the editor for any modifications. In all other cases, the payload is directly uploaded and configured during the addition of service.

Adding a Service – Using RR Pairs

Service Virtualization allows users to create service using request/response(RR) pairs that contain information in the form of HTTP headers and a body. It is convenient to use when their backend server is under development and user don’t have a recording setup, however, they have request-response pairs of that backend.

RR pair consists of one request and one or more responses that follow the below naming conventions:

  • The file name consists of a prefix, a suffix, and optionally a file extension.
  • The prefix is a unique identifier that is used to tie requests and response in a pair.

User must use the same prefix in all the file names that correspond to a particular pair.

  • The suffix of a request file is -req.
  • The suffix of a response file is -rsp.

Example 1:

⦁    GetLoyaltyReward-req.xml

⦁    GetLoyaltyReward-rsp.xml
Here in this pair, GetLoyaltyReward is a prefix and -req/-rsp is the suffix and .xml is file extension.
Example 2: In case the user has multiple responses, add a number to the end of each response suffix. There are four responses.

  • GetLoyaltyReward-req.xml
  • GetLoyaltyReward-rsp.xml
  • GetLoyaltyReward-rsp1.xml
  • GetLoyaltyReward-rsp2.xml
  • GetLoyaltyReward-rsp3.xml

Request file consists of the following sections:

  • HTTP request line (e.g. POST /api/v2/merchants/payment HTTP1.1)
  • Zero or more HTTP headers
  • EMPTY LINE (there should be only one empty line)
  • Payload (XML, JSON, TXT, …)

An example of a REST request file:

POST /api/v2/merchants/payment HTTP/1.1Accept: application/jsonContent-Type: application/jsonContent-Length:216{  “amount”: {    “amount”: 10.5,    “currency”: “USD”  },  “paymentMethod”: “wallet”,  “PayPalWallet”: {    “Balance”: 956.23,    “WalletID”: “UX876QAC”  },  “transactionChannel”: “Web Online”}

In the case of a SOAP request, the request file can have only a payload. (see note for more detail). An example of a SOAP request file:

POST /loyalty/loyaltyservice/v1 HTTP/1.1Content-Type: application/soap+xml; charset=utf-8
Content-Length:479 <? xml version=”1.0″ encoding=”UTF-8″?><soap: Envelope>   <soap: Header>      <v1: request_header>         <v11: requesterName>POS</v11: requesterName>         <v11: requestDate>2013-05-09</v11: requestDate>      </v1: request_header>   </soap: Header>   <soap: Body>      <v1: searchRewards>         <v11: provider>cavisson</v11: provider>         <v11: emailAddress>perfemail1@cavisson.com</v11: emailAddress>      </v1: searchRewards>   </soap: Body></soap: Envelope>

Similarly, a response file consists of the following sections:

  • HTTP response line (e.g. HTTP/1.1 200 OK)
  • Zero or more HTTP headers
  • EMPTY LINE (there should be only one empty line)
  • Body (XML, JSON, TXT, …)

An example of a response file:

HTTP/1.1 200 OK

{

  “orderAmount”: 10.5,

  “currency”: “USD”,

  “completable”: true,

  “timestamp”: “04-15-22/03:05”,

  “transactionReferences”: [

    {

      “transactionId”: 3495717101571,

      “transactionType”: “InitiateDebit”,

      “transactionDate”: “04-15-22/03:05”,

      “transactionDesc”: “Transaction Accepted”,

      “status”: “Processed”,

      “paymentMethod”: “PayPal”

    }

  ]

}

An example of a SOAP response file:

HTTP/1.1 200 OK

<?xml version=”1.0″ encoding=”UTF-8″?>

<soap: Envelope xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/”>

   <soap: Body>

      <searchRewardsResponse xmlns=”http://service.cavisson.com/Loyalty/LoyaltyService/v1″ xmlns:ns1=”http://schema.cavisson.com/Loyalty/LoyaltyData/v1″>

         <ns1: returnCode>0</ns1: returnCode>

         <ns1: accounts>

            <ns1: account>

               <ns1: membershipIdentifier>

                  <ns1: provider>cavisson</ns1: provider>

                  <ns1: identifier>841010</ns1: identifier>

               </ns1: membershipIdentifier>

               <ns1: emailAddress>

                  <ns1: emailAddress>perfemail1@cavisson.com</ns1: emailAddress>

               </ns1: email Address>

               <ns1: loyaltyCardFlag>false</ns1:loyaltyCardFlag>

               <ns1: tier>BASE</ns1: tier>

               <ns1: member>

                  <ns1: phoneNumbers>

                     <ns1: phoneNumber>

                        <ns1: phone>1306295190</ns1: phone>

                        <ns1: type>HOME</ns1: type>

                     </ns1: phoneNumber>

                  </ns1: phoneNumbers>

               </ns1: member>

            </ns1: account>

         </ns1: accounts>

      </searchRewardsResponse>

   </soap: Body>

</soap: Envelope>

Steps to Add a Service using RR Pair

  1. On the Services menu, go to Add and click the Using RR Pairs option as shown in the below figure.
Figure 146: Using RR Pairs

2. This displays the RR Pairs Service Configuration

Figure 147: RR Pairs Service Configuration Window

3. Now select the option of how the user wants to choose RR pairs either by Using Files or Directory. When a user selects “files”, then they should upload files with -req and -rsp format. When a user clicks “Directory”, they need to create a directory of request and response files in their local machine and upload it as needed.

4. Next click on Choose RR Pairs and select the RR pairs that the user wants to upload.

Figure 148: RR pairs

5. In other case select the option Using Directory, click on Choose Directory, and select the directory of RR pairs.

Figure 149: Using Directory

6. Once the user selects the required files or directory, click on Upload. This displays captured URLs under Captured URL List.

Figure 150: Captured URL List

7. Here Request displays the request header with the request payload. 

  Request payload displays the request payload only.

  Response displays the response header with the response payload.

  Response Payload displays the response payload only.

8. If the user wants to Reset the table data, they can click the button “Reset”.

Figure 151: Create Service selection

9. Once the selected files or directory gets uploaded we can click on Create Services this will get our service enlisted on Manage Service UI.

10. Other options like Cancel, Filter and create & activate services are for canceling the service, applying filters in Captured URL list, and creating and activating the service respectively.

Figure 152: Service Name Selection

Notes:

  1. The service name will be created by file name however it is editable, the user needs to click the name and edit it.
  2. In case the SOAP request does not have a request line then the service is created with service url “/cav_soap_service”. And other services without request line are added as a template in the same service.
  3. While creating a service, the service virtualization server does auto correlation i.e. it automatically detects the value in the response that matches the request and replace those values with parameters.

Adding a Service – Using WSDL

Service Virtualization provides a feature through which all client services, which are exposed through WSDL, can be imported in Service Virtualization. User needs not create the services manually, write the requests, and response in Service Virtualization. They will get all the exposed Services/Operations in the drop down and can select the Service/Operations from there, which need to be migrated.

WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services).

WSDL is often used in combination with SOAP and XML Schema to provide web services over the Internet. A client program connecting to a web service can read the WSDL to determine what functions are available on the server. Any special datatypes used are embedded in the WSDL file in the form of XML Schema. The client can then use SOAP to call one of the functions listed in the WSDL.

Steps to Add a Service using WSDL

  1. On the Services menu, go to Add Services and click Using WSDL as shown in the figure below.
Figure 153: Using WSDL

2. This displays the WSDL Service Configuration

Figure 154: WSDL Configuration

3. Specify the URL of the WSDL file.

For example: http://www.dneonline.com/calculator.asmx?wsdl

4. Click the Fetch Service Configurations This fetches the configuration of the WSDL file. Note: User can either import the service using a file by uploading the WSDL file or specify the request/response in the text area and add the service.

5. Fetch Service provides all the services, which are available to the Client and all operations associated with that service. Select the service from the list and the operation corresponding to the service.

Figure 155: Fetch Service Configuration

6. Selection of URL. Add Detail over here

7. Click the Create Services The service is added successfully.

Figure 156: Captured URL List

This adds the service to the Services list.

Figure 157: Added Service

Note: A user cannot save a WSDL service with a name that already exists. While doing so, an error message “Service Name is already there. Please assign another name” is displayed.

Adding a Service – Using Open API

Service Virtualization provides a feature through which all client services, which are exposed through Open API, can be imported into Service Virtualization. User need not create the services manually, write the requests, and response in Service Virtualization. User will get all the exposed Services/Operations in the drop down and can select the Service/operations from there, which needs to be migrated.

Open API is an open-source software framework backed by a large ecosystem of tools that helps developers design, build, document, and consume RESTful Web Services. While most users identify Open API by the Open API UI tool, the Open API toolset includes support for automated documentation, code generation, and test-case generation.

User needs to provide the JSONlYAML through which all the services can be exposed and added in Service Virtualization.

Steps to Add a Service using Open API

  1. On the Services menu, go to Add Services and click Using Open API option as shown in the below figure.
Figure 158: Using Open API

2. This displays the Open API Configurations

Figure 159: Open API

3. Browse the URL of the open api document.

For example: https://petstore.swagger.io/v2/swagger.json

4. Click the Fetch Open API Specification This fetches all the services, which are available to the Client and all operations associated with that service.

Figure 160: Open API(using URL)

5. Click This displays the resource list with the service and template name. User can select one or more of them to add a service.

Figure 161: Resource List

6. Click the Create Service This adds to the service.

7. Optionally, the user can test a service by clicking on the Test under the Action They can either do a test on the original service or some other endpoint. Also, there are other options example to give query parameter, header, and modification of request payload. User can further save the response by clicking on the Save button. This would create a service with this saved response.

Figure 162: Action-Test Selection
Figure 163: Test Configuration

For test configuration, fill in the following fields:

  • Method: Enter the HTTP methods for retrieving from and sending data to a server. GET, POST, PUT, PATCH, and DELETE are the five most common HTTP methods.
  • Scheme: Select HTTP or HTTPS for the scheme.
  • Host: Enter the host name in this field.
  • Port: Fill in the port number.
  • URL: Write the URL of Open API.
  • Query: Enter the query/status.
  • Header: It is the name of the header which is to be given.