Service Virtualization

Expand all | Collapse all

Response to read value from header instead of request parameter

Jump to Best Answer
  • 1.  Response to read value from header instead of request parameter

    Posted 05-03-2019 07:38 AM

    Hello Team,

     

    I am looking for help to create VS.

    I have few headers in HTTP request, like below. response will have to read the business id from the header in the request and provide response accordingly with the value in the business-id.

    How do I achieve this without reading as request parameter.

     

    Sample Request:

    x-session-id:

    x-request-id:

    x-business-id: 1234

     

    Sample Response

    OK

    x-business-id:1234



  • 2.  Re: Response to read value from header instead of request parameter

    Posted 05-03-2019 11:20 AM

    Hi,

     

    When the incoming HTTP request is processed by the HTTP Listen Step and it creates a request object from this (lisa_vse_request) then all HTTP header present in the incoming request will have been created as metadata parameters in the request object.

     

    If you need some of the request headers for matching with the correct response in your VSI

    Use a Request Data Manager DPH to move parameters from metadata to arguments so you can use them in your signature in your VSI (once in your signature you can mark them as magic string to be able to use the values in your responses)

     

    If you only need the metadata parameter values for data in your responses

    Use a Request Data Copier DPH to copy the metadata parameters to properties, following that you can use the property names within double curly braces in your responses {{}}

     

    When using a Request Data Copier my advice is always to create the properties with a suffix that starts with "request_ ...", any property whose name start with request_will be deleted from the environment as soon as the Respond step delivers the response to the client. So you will never have the risk that the response for your next request will contain a data value from your previous request.

     

    Cheers,

    Danny



  • 3.  Re: Response to read value from header instead of request parameter

    Posted 05-03-2019 11:23 AM

    I now noticed your example. So for a short answer I would say:

     

    • Add a Request Data Copier, configure it with suffix "request_meta_" for the metadata parameters
    • In your responses, add {{request_meta_x-business-id}} where needed

     

    Cheers,

    Danny



  • 4.  Re: Response to read value from header instead of request parameter

    Posted 05-04-2019 02:05 AM

    Correction: configure it with prefix "request_meta_" for the metadata parameters



  • 5.  Re: Response to read value from header instead of request parameter

    Posted 05-06-2019 05:29 AM

    Thank you for your response. I have tried to add metadata and response field is added, please find attached print screens for reference.

     ( tried to update metadata this way as well)

    I am still not getting the response as expected.

    I have attached all print screens, request you to take a look and guide me.



  • 6.  Re: Response to read value from header instead of request parameter

    Posted 05-06-2019 06:04 AM

    As far as I can tell you are missing the Request Data Copier Data Protocol Handler.

    You cannot add this DPH when working in the portal, you will have to edit this VSM in the Workstation.

     

    Cheers,

    Danny



  • 7.  Re: Response to read value from header instead of request parameter

    Posted 05-06-2019 06:13 AM

    ok, is the way that DPH is updated correct as per my print screens? If yes, I will follow the same using workstation. Else, please let me know correct way to update based on my example given.



  • 8.  Re: Response to read value from header instead of request parameter
    Best Answer

    Posted 05-06-2019 06:26 AM

    If you search the documentation for “Request Data Copier” you can find some context around the DPHs.

    I don’t think a specific procedure is described for each DPH, a DPH is basically a filter, so you can also search on how to add filters to workflows.

     

    It will go something like this:

     

      1.  Open the VSM in the Workstation

      2.  Select the Listen Step

      3.  Add a filter

      4.  Select Virtual Service Environment categorie, there is only one filter in there (the DPH)

      5.  From the Filter config, select “Request Data Copier” (RDC) in the dropdown list

      6.  In the RDC pane, select “meta” checkbox, add “request_meta_” in the entry field before <md-name>

      7.  Save the VSM, Deploy

     

    Cheers,

    Danny