Update VSE request headers before going to LIVE System
search cancel

Update VSE request headers before going to LIVE System

book

Article ID: 378591

calendar_today

Updated On:

Products

Service Virtualization

Issue/Introduction

This article will provide information on updating VSE request headers before going to LIVE System or for doing any other customization in the VS.

Environment

DevTest release 10.8.4.

Resolution

The below code can be used in Scripted assertion or in Execute Script step after the HTTP Listen step to update the lisa.vse.request headers test-key & auth with the new values. 

--------------
import com.itko.util.ParameterList;
import com.itko.util.Parameter;
 
ParameterList newmetadata = lisa_vse_request.getMetaData();
newmetadata.setParameterValue("test-key", "test123");
newmetadata.setParameterValue("auth", "Basic 123");
lisa_vse_request.setMetaData(newmetadata); 
return true;
-------------------
 
NOTE: Set the logic of the Scripted Assertion to If False, Fail the test. Assertion should never fail unless the code is incorrect.
 
The above code will work for setting the headers for VSE request but not for the HTTP Transaction. We have the patch patch_DE669605_10.8.4_GA.jar and the below code to add/update the HTTP Transaction headers. The code can be added in a Scripted Assertion or in a Execute Script step and set the the logic to go to next step accordingly.
 
-----------------------------------------------------------
import com.itko.lisa.vse.http.HTTPTransaction;
HTTPTransaction transaction = ((HTTPTransaction) testExec.getStateObject("lisa.vse.http.current.transaction"));
transaction.updateRequestHeaderBlockHost("SCRIPTABLEHOST.com");
testExec.setStateObject("lisa.vse.http.current.transaction", transaction);
transaction.updateRequestHeader("consumer-key","nEhvbBHubj7gkSHoQEeBKvmx0h1VpRoj");
transaction.updateRequestHeader("authorization", "Bearer afwyuqwnfvdhfrddsyuklh"); 
transaction.addRequestHeader("headertoadd", "headervalue");
----------------------------------------------------------
 
 
Instruction for applying the patch on VSE server:
. Stop VSE and other services
. Download the patch file  patch_DE669605_10.8.4_GA.jar
. Place patch_DE669605_10.8.4_GA.jar in <DevTest-Home>/lib/patches folder
. Start VSE and other services.
 
With above changes in VSM, HTTP Transaction Headers can added or updated.
 
If anyone looking to modify the HTTP Transaction headers in 10.8.4, please open a support case and request the patch patch_DE669605_10.8.4_GA.jar.