How to update VSE request and send it to LIVE system
search cancel

How to update VSE request and send it to LIVE system

book

Article ID: 127510

calendar_today

Updated On: 06-03-2024

Products

CA Application Test CA Continuous Application Insight (PathFinder) Service Virtualization

Issue/Introduction

There will be some scenarios where VSE request need to be modified before going to the LIVE system (LIVE Invocation step). This article will provide information on how to achieve it.

For example, below is the sample request hitting the VS. 

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <getTransactions xmlns="http://ejb3.examples.itko.com/">
            <accountId xmlns="">1313094687566198</accountId>
            <from xsi:type="xsd:dateTime" xmlns="">2011-08-04T20:35:37.660Z</from>
            <to xsi:type="xsd:dateTime" xmlns="">2011-08-11T20:35:37.660Z</to>
        </getTransactions>
    </soapenv:Body>
</soapenv:Envelope>

When the request go to LIVE system the value "1313094687566198" need to be changed to "2567123476542345".

Environment

All supported DevTest releases.

Cause

N/A

Resolution

The property "lisa.vse.http.current.transaction" holds the current transaction information in VS and lisa.vse.http.current.transaction.body" holds the request payload.

To change the VSE request payload, need to capture it first and modify that with the desired value and then set the new payload in the current transaction.

In the VSM, this can be done in an "Execute Script" step or in a "Scripted Assertion" with the below Beanshell code before the LIVE Invocation step.

--------------------------------------------------------------
import com.itko.lisa.vse.http.HTTPTransaction;
import com.itko.lisa.vse.http.Transaction;

String OriginalRequestBody = testExec.getStateValue("lisa.vse.http.current.transaction.body"); // Original request payload hitting the VS
String MofifiedRequestBody = OriginalRequestBody.replace("1313094687566198","2567123476542345");   // Original Text to be replaced- "1313094687566198"  Replacement Text - "2567123476542345"

HTTPTransaction transaction = ((HTTPTransaction) testExec.getStateObject("lisa.vse.http.current.transaction"));  // Get the current transaction
transaction.setPayload(MofifiedRequestBody);  // Setting the new payload
return testExec.getStateValue("lisa.vse.http.current.transaction");  // Returning the current transaction with the updated payload
------

Additional Information

The functionality in this article is customization. The code provided in the instructions is very basic and it can be extended per the functionality.