Service Virtualization

  • 1.  I am trying to get the HTTP-Response-Code but it is not getting set.

    Posted Nov 26, 2018 03:47 PM

    I'm using a request data copier (filtering on lisa.vse.response) in a filter on my "Virtual HTTPS Responder" step, trying to get the value of the HTTP response code.  I have checked the Meta option, and I am using the prefix:  meta_   and I am expecting to have the following variable to reference:  {{meta_HTTP-Response-Code}}.  I get nothing tho.

     

    This same approach is working for the request data, finding {{meta_HTTP-Method}}, {{meta_HTTP-URI}} etc.

     

    Thanks for any help you can offer.

     

    JT



  • 2.  Re: I am trying to get the HTTP-Response-Code but it is not getting set.

    Posted Nov 26, 2018 05:58 PM

    Jeff,

     

    I haven't used the Request Data Copier DPH/filter on the Responder step so I can't confirm whether it will work as you expect it will on Response object in the Responder step, or if it's limited to Request objects in the Listen step.

     

    However, the following approach will allow you to access the HTTP-Response-Code value:

     

    1. Add Scriptable Data Protocol Handler on the Responder step (Right click Responder > Add filter > Virtual Service Environment > Data Protocol Handler. Select Scriptable Data Protocol from drop down)

    2. Type in "lisa.vse.response" into the "Filter in" field

    3. Select "Process Responses" radio button.

    4. Select "Response - Playback" tab. It should be configured as shown below:

    5. Type in the following script:

    %beanshell%

    // You can use %beanshell%, %groovy% or %javascript% or some other installed JSR-223 scripting language
    // This example is for beanshell

    import com.itko.util.ParameterList;

    // Metadata is a ParameterList
    ParameterList metadata = lisa_vse_response.getMetaData();

    // Access meta data using the key HTTP-Response-Code
    String responseCode = metadata.getParameterValue("HTTP-Response-Code");

    // save it into a property
    testExec.setStateValue("HTTP_Response_Code", responseCode);

     



  • 3.  Re: I am trying to get the HTTP-Response-Code but it is not getting set.

    Broadcom Employee
    Posted Nov 27, 2018 12:12 AM

    Hi Jeff,

    I would be interested to learn about your use case for retrieving the response's HTTP-Response-Code at such a late time in the flow? I could make a guess like writing out some reporting on the transaction that was just processed by the virtual service but maybe you're doing some other interesting stuff?

     

    Cheers,

    Danny