Service Virtualization

  • 1.  How to get the Request headers in Lisa or is there any default property Lisa creates that captures the request headers.

    Posted Sep 12, 2017 10:34 AM

    How to get request headers in Lisa?



  • 2.  Re: How to get the Request headers in Lisa or is there any default property Lisa creates that captures the request headers.

    Posted Sep 12, 2017 12:06 PM

    In the VSM, Select the Listen Step, Add a Filter, and look in HTTP/HTML.  Review the available filters for parsing header values and cookies.

     

    If scripting is your approach, the lisa_vse_request.getMetaData() returns a ParameterList of headers. 

    For example, 

    com.itko.util.ParameterList metaData = lisa_vse_request.getMetaData();

    Review the SDK for methods available on the ParameterList object.

     

    The MetaData captured during recording is seen in the VSI under the MetaData tab. The VSI depicts only the headers observed during recording, whereas the Filters and Scripts obtain the desired header data on the specific incoming request at runtime.



  • 3.  Re: How to get the Request headers in Lisa or is there any default property Lisa creates that captures the request headers.

    Posted Sep 12, 2017 12:20 PM

    Thanks Joel , Actually we are  not working on virtual services , we are performing web service /API Automation , I have to capture Request headers and body while running a REST Step.

    Thanks in advance.



  • 4.  Re: How to get the Request headers in Lisa or is there any default property Lisa creates that captures the request headers.
    Best Answer

    Broadcom Employee
    Posted Sep 12, 2017 01:05 PM

    Run the REST testcase in the ITR,  Click on the Step and look at the properties.

     You will see a propertycalled   lisa.<stepName>.httpheaders.rsp.  This should have the header information.  

     

    Thanks

     

    Shiney 



  • 5.  Re: How to get the Request headers in Lisa or is there any default property Lisa creates that captures the request headers.

    Broadcom Employee
    Posted Sep 12, 2017 01:45 PM

    Isn't the property name called lisa.<stepName>.http.headers?  I don't see a property named as lisa.<stepName>.httpheaders.rsp

     

    lisa.<stepName>.http.headers will contain the headers extracted from the response. The original question was how to get the request headers



  • 6.  Re: How to get the Request headers in Lisa or is there any default property Lisa creates that captures the request headers.

    Posted Sep 13, 2017 03:09 AM

    Thanks Shiney and Prem

     

    Actually Prem is correct ,my question is not to capture the response headers but my question is how to capture the request headers.

    Response header property is created in properties. please find the below image. I want to capture the property containing request headers.



  • 7.  Re: How to get the Request headers in Lisa or is there any default property Lisa creates that captures the request headers.

    Posted Sep 13, 2017 08:14 AM

    To access the headers passed in on a Test Case call, you will need to code a small amount of script.  Here is a picture of the flow so you can see what is happening.

    The Rest Call will set up two headers in this example.

    The Retrieve and Print Request Headers script (JSR-223) step will print the ParameterList containing these headers.

    The key to accessing the request headers is to access the headers using the Step Name.

    import com.itko.util.ParameterList;

    // RESTNodeName is the name of the REST Step having the request headers

    String RESTNodeName = "RESTGET";
    ParameterList pl = testExec.TestCase.getNode( RESTNodeName ).getHeaderFields();

    // return the ParameterList as a string

    // add more code to iterate over the list if necessary

    return pl.toString();

    The output of the last two steps, when executed, looks like this:

     

    The Output Log Message is set up with the following code

    Header Details:

    ***********************

    {{lisa.RESTGET.http.headers}}

     

    And, it returns:



  • 8.  Re: How to get the Request headers in Lisa or is there any default property Lisa creates that captures the request headers.

    Posted Sep 13, 2017 08:46 AM

    Thanks Joel,

     

    I tried the above code but am getting the below error.

     

    execution error so we assume false: javax.script.ScriptException: bsh.EvalError: Sourced file: inline evaluation of: ``import java.lang.*;  import com.itko.util.ParameterList;  import com.itko.lisa.w . . . '' : Typed variable declaration : Error in method invocation: Method getHeaderFields() not found in class'com.itko.lisa.ws.nx.NxWSStep' : at Line: 11 : in file: inline evaluation of: ``import java.lang.*;  import com.itko.util.ParameterList;  import com.itko.lisa.w . . . '' : .getHeaderFields ( )
     in inline evaluation of: ``import java.lang.*;  import com.itko.util.ParameterList;  import com.itko.lisa.w . . . '' at line number 11

     

    could you please help ,what can be the reason?



  • 9.  Re: How to get the Request headers in Lisa or is there any default property Lisa creates that captures the request headers.

    Posted Sep 13, 2017 09:25 AM

    What version of DevTest are you using?  The example I used was REST and is taken from DT 10.1.0.

     

    It looks like your step uses a NxWSStep class which returns a CustomHTTPHeaderInfo class rather than a ParameterList.  

    The below is just a hack...  See if this works.  If not, I will have to find some time to play with it to see if I can print a list of the headers.

     

    //WEB SERVICE ACCESS TO REQUEST HEADERS WHEN THE STEP IS NxWSStep

    import com.itko.lisa.dynexec.axis.CustomHTTPHeaderInfo;

    import com.itko.util.ParameterList;

    // WS_STEP_NAME_HERE -- replace this with the name of your WebService Step

    CustomHTTPHeaderInfo chi = testExec.TestCase.getNode( "WS_Step_NAME_HERE" ).getHeaderInfo();

    ParameterList pl = chi.getHeaders();

    return pl.toString();