Service Virtualization

  • 1.  Can We Match on Request Meta Data?

    Posted Aug 23, 2016 04:36 PM

    I am working with a REST service and DevTest 9.0.

     

    The REST call looks very similar to this ::

    GET /instance/0123-456-789/

     

    This REST call will return a different payload based on the "User-Agent" key-value pair passed in the request meta data.

     

    For example ::

    If the request Meta Data "User-Agent" is equal to "ruby-openid/2.7.0 (x86_64-linux)"

    Then the REST service will send back an XML payload in the response.

     

    If the request Meta Data "User-Agent" is equal to "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"

    Then the REST service will send back an HTML payload in the response.

     

     

    Question ::

    Is there a way that I can return either the XML payload, or the HTML payload, depending on what "User-Agent" value was received in the request Meta Data?



  • 2.  Re: Can We Match on Request Meta Data?

    Posted Aug 23, 2016 05:03 PM

    Yes you can simply achieve this by adding match script  for the transaction you have to match

     

    Example if you have to match if the User-Agent is Android , you can sample add match script as below and return this response as JSON.

     

    Match Script :

    PastedGraphic-1.png

    Response :

    PastedGraphic-2.png

     

    Response Header ;

    PastedGraphic-3.png

     

    if you user agent is “iphone “ you want to return the response as XML then change the content type to XML on Response headers

     

    Match Script :

    PastedGraphic-4.png

     

    Response :

    PastedGraphic-5.png

     

    Response Header :

     

    PastedGraphic-6.png

     

     

     

    Thanks ,

     

    Vamsi



  • 3.  Re: Can We Match on Request Meta Data?

    Posted Aug 24, 2016 01:18 PM

    kurva01 thanks for the suggestion.  I tried it out for a bit, but couldn't get it to do what I needed.  I'm going to try out the suggestion from Daniel_Bingham.  Thanks again.



  • 4.  Re: Can We Match on Request Meta Data?
    Best Answer

    Posted Aug 24, 2016 01:07 PM

    By far the easiest solution would be to use the Request Data Manager DPH and copy that entry from the MetaData to the Argument list for the request and then let VSE do its normal matching.  No need to maintain match scripts.



  • 5.  Re: Can We Match on Request Meta Data?

    Posted Aug 24, 2016 01:16 PM

    Thanks Daniel_Bingham !
    I was wondering about that last night, after I struggled with trying to get the other suggestion to work.
    I will give your suggestion a try.



  • 6.  Re: Can We Match on Request Meta Data?

    Posted Aug 30, 2016 04:16 PM

    Hi Jeff,

     

    Did you have a chance to test out Daniel's suggestion? If it worked, please be sure to mark his response as correct so other users can benefit from his response.

     

    Thanks!

    Melanie