Virtualizing a web service whose request and response pair are of different format
search cancel

Virtualizing a web service whose request and response pair are of different format

book

Article ID: 95760

calendar_today

Updated On:

Products

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

Issue/Introduction

The request data comes as String parameter over HTTP and the response is sent back as XML data protocol over HTTP. How to virtualize this functionality.

Below are the sample request and response
Request: [Test=XX] [ProdId=yutr] [TestID=9876] [NA=12.XX.XX3] [VALT=XX.XX.X.XX] [TS=20183]
Response : Any XML response

Environment

Supported DevTest Environments.

Cause

HTTP request is not in XML or in JSON but in String so need to customize it create a VS.

Resolution

Created VS with RR Pairs option as below. 
. Provided the VSI and VSM names. 
. Configured the Protocol information. 
. REST DPH is automatically added. 
. Added Scriptable DPH and Delimited Text DPH. 
. Added the below code to modify the request to have delimiter as "] [" in Scriptable DPH: 
------- 
%beanshell% 
import com.itko.util.ParameterList; 
// Manipulate request body text 
String theBody = lisa_vse_request.getBodyText(); 
String NewBody = theBody.substring(1,theBody.length()-1); 
-------- 
. Configured Delimited Text Data Protocol with Name/Value pairs as "[]" 
. With the above DPH's, request is parsed with the below arguments and VS is created without any issue. Test=XX,ProdId=yutr,TestID=9876,NA=12.XX.XX3,VALT=XX.XX.X.XX,TS=20183