Service Virtualization

  • 1.  how to extract values from http listen step

    Posted Feb 07, 2017 07:39 AM

    Hi

     

    I have a requirement where I need to filter the values in "http listen step" from the request URI and then use it in other steps.

     

    For eg: I have a REST service as below:

     

    GET /account/123/child/345

     

    Could anyone please help me how can I extract only 123 and 345 from the URI in http listen step and store it in separate properties to use later.

     

    Note: I need to do that in HTTP Listen Step itself before executing VS Image Response Selection step.



  • 2.  Re: how to extract values from http listen step
    Best Answer

    Posted Feb 07, 2017 07:57 AM

    You need to be using the REST Data Protocol Handler filter in your Listen Step.  Normally, you would add and configure this DPH during recording.  

    Refer to: REST Data Protocol Handler - DevTest Solutions - 10.0 - CA Technologies Documentation  for information on how to parameterize your URI.  The DPH should be capable of implementing the behavior you want.



  • 3.  Re: how to extract values from http listen step

    Posted Feb 07, 2017 08:08 AM

    Thanks Joel. But the documentation refers to parameterize the values during service creation to handle different values in the incoming request.

    But my question is that, how can I use the parameterized values even before VSI step since I don't see any properties referencing to these parameters in HTTP LISTEN STEP.



  • 4.  Re: how to extract values from http listen step

    Posted Feb 07, 2017 08:45 AM

    If your service does not have the REST DPH and/or you are not able to re-record, you will need to make manual adjustments in the VSM Listen Step (to add and configure the REST DPH) and the VSI (to support the changes the DPH will apply when it executes).

     

    When you use the REST DPH, URLPARAM0 will map to your account number (123) and URLPARAM1 will map to your child id (345).  

     

    The REST DPH will parse the URI and create two arguments. It will also alter the Operation name when the URI and rules you have applied are executed. 

     

    The parsed arguments are passed into the VSI as URLPARAM0 and URLPARAM1.

    The REST DPH will also modify the Operation in the VSI to: GET /account/{URLPARAM0}/child/{URLPARAM1}

     

    So, for the operation, GET /account/{URLPARAM0}/child/{URLPARAM1}, you will see two arguments in addition to any query string data or body data that may have also been parsed.

    One would use the specific transaction feature to compare these properties for:

    URLPARAM0 = 123

    URLPARAM1 = 345

    to select the desired response.  DevTest does it this way so that additional account IDs and Child IDs simply fall under a single operation.  

     

    Consider the VSI picture below.  Notice the difference in the Operation.  It no longer carries the value that came in on the REST call; rather the parameter URLPARAM0.  The REST DPH did this.  Also, notice that the URLPARAM0 has been copied into the Argument list. (Some information in this VSI is intentionally hidden).  The tie breaker between one transaction and another is handled by the comparison operator (i.e., when the URLPARAM0 = "1111111111" and query = "newest" then send this response).

     

    Once the REST DPH fires, you can use script logic to access the if (lisa_vse_request.getArgumentList().containsKey("URLPARAM0") ) to check if the argument was parsed.

     

    Hope that help clarify a bit.



  • 5.  Re: how to extract values from http listen step

    Posted Feb 08, 2017 06:57 AM

    Thanks Joel. I used the "Create property based on surrounding values" filter and am able to save the required values into properties.

     

    This solved my question.