Service Virtualization

Expand all | Collapse all

Pass the header value from the request to response in virtualization

Jump to Best Answer
  • 1.  Pass the header value from the request to response in virtualization

    Posted 03-22-2018 06:12 PM

    Hi,

     

    A real request from a application to VSE contains a header "Origin : ***.***.***.***:xxxx".  This value changes from where the app is running from. I want to extract that value from the request header and pass it alongwith my response header. I'm not getting a way around this. Please help.

     

    My sample lisa.vse.request : 

     

    Request {id=0, operation="POST /cars/inventory", arguments=, attributes=HTTP-Segment-Attr-0=cars&HTTP-Segment-Attr-1=inventory, metaData=HTTP-Method=POST&HTTP-URI=/cars/inventory&HTTP-Version=1.1&cache-control=no-cache&Postman-Token=ae8e3d6b-88d0-436d-8db7-149195194cf6&Origin=localhost:8701&User-Agent=PostmanRuntime/3.0.9&Accept=*/*&Host=***.***.***.***:xxxx&accept-encoding=gzip, deflate&content-length=0&Connection=keep-alive&lisa.vse.request.client.id=127.0.0.1:62902&matchedRule=not found, matchTolerance=Exact, binary=false, body=(non-binary)[0 bytes] <null>}

     

     

    J_NeSmith

    monika_mehta



  • 2.  Re: Pass the header value from the request to response in virtualization
    Best Answer

    Posted 03-22-2018 06:55 PM

    To extract the value from request header you can use one of two approaches:

     

    1. Use Request Data Manager DPH  to copy the value of Origin from metaData to the list of arguments.

     

    https://docops.ca.com/devtest-solutions/10-2/en/using/using-ca-service-virtualization/using-devtest-workstation-with-ca-service-virtualization/creating-service-images/using-data-protocols/request-data-manager-data-protocol

     

    or

    2. Use a XML xpath filter to extract the value of Origin from lisa.vse.request (assuming your model is of More Flexible type)

     

    https://docops.ca.com/devtest-solutions/10-2/en/reference/filter-descriptions/xml-filters/xml-xpath-filter

     

    In the first case, assuming the argument name is incomingOrigin, its value will be available as request_incomingOrigin that can be used in response. You may need to change the Comparison Operation to Anything for this argument as this will be a synthetic argument added to be used in the response.

     

    In the second case, the name of property used to store the xpath filter would have the value to use in your response.