Not able to Set Header in VSI Response meta
search cancel

Not able to Set Header in VSI Response meta

book

Article ID: 118424

calendar_today

Updated On:

Products

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

Issue/Introduction

Have created a DevTest virtual service based on Swagger.

Need to respond back with different response code based on an encrypted field. Doing decryption and matching in VSM and populating different response codes and description.

When trying to set the VSI response meta with these fields, implementation is failing for at http respond step.

• Wanting to save the HTTP-Response-Code to a DevTest property in the VSI.
• It only works if the value is hardcode (401 in this case)
• Getting error: 
Message: The response object is not formed properly. It is missing the response code meta data entry or it is invalid: code=401

Environment

All supported DevTest releases.

Cause

N/A

Resolution

Create a scriptable DPH with this code: 

import.com.itko.util.Parameter; 
import com.itko.util.ParameterList; 

ParameterList metaData = new ParameterList(); 
//com.itko.util.ParameterList metaData = lisa_vse_response.get(0).getMetaData(); 
metaData.addParameter(new Parameter("HTTP-Response-Code", "401")); 
metaData.addParameter(new Parameter("HTTP-Response-Code-Text", "Unauthorized")); 
lisa_vse_response.get(0).setMetaData(metaData); 

 

Additional Information