Service Virtualization

Expand all | Collapse all

API based virtual service

  • 1.  API based virtual service

    Posted Sep 23, 2016 04:18 PM

    we have to build a api based virtual service and url is as looks below .. it is get call.. (we also have post as well)

     

    http://serverhost:8443/card_details/v1/debit-card/accounts/5556664/statuses 

     

    Here the input is account number i.e., 5556664.. every time new account number will be sent here from client to LISA.. 

     

    I need to extract this account number and do several match rules/transactions in VSI.. 

     

    can you please advise how can I extract this and make it as request argument in VSI .. what are the data protocols I need to use in model to achieve this.. ..



  • 2.  Re: API based virtual service

    Broadcom Employee
    Posted Sep 23, 2016 04:31 PM

    It looks to me like a REST DPH is what you want, because you'll be able to extract the v1 as URLPARAM_0 request argument and 5556664 as URLPARAM_1 request argument



  • 3.  Re: API based virtual service

    Broadcom Employee
    Posted Sep 23, 2016 04:32 PM


  • 4.  Re: API based virtual service

    Posted Sep 29, 2016 03:21 PM
      |   view attached

    Thanks Rick.Brown Prem_Bairoliya for your inputs..

     

    However I have tried the same and could not get.. Please find my attached project.. 

     

    In this case my client is calling the endpoint as http://lisa_host:8001/web/CreditLimit?token=00000043547

     

    and this is get method call... Now I have deployed this service using the same endpoint but the problem I am facing is how can I make the token as Parameter here.. ? when I am creating this virtual service using RR Paris I did not get any option to choose this as Param.. 

     

    Currently my clients can pass only 00000043547 this value in token as this is endpoint.. if I made this parameter and and in VSI if I use this to check the condition then it will be better.. please suggest 

    Attachment(s)

    zip
    API_Virtualisation.zip   12 KB 1 version


  • 5.  Re: API based virtual service

    Posted Sep 29, 2016 03:37 PM

    Please see the snap below... basically I am trying to make the value of token to parameterized ..

     



  • 6.  Re: API based virtual service

    Broadcom Employee
    Posted Sep 29, 2016 03:49 PM

    It looks like you only have the one transaction so it's using only one token number. That number shouldn't be in your base path (you'll get NO MATCH when using a different token), so what happens if you generate from multiple transactions with different token numbers?



  • 7.  Re: API based virtual service

    Broadcom Employee
    Posted Sep 29, 2016 04:16 PM

    Looking at your image file it looks like the token has been parameterized. To achieve what you're looking for simply do the following:

     

    1. Remove ?token=00000043547 from your base path in the model

    2. Add additional transactions in your image to reflect other token values 



  • 8.  Re: API based virtual service

    Broadcom Employee
    Posted Sep 29, 2016 05:01 PM

    I just added a second transaction, with that number, to the RR Pair directory, and the generation wizard comes up with this:

    Generation wizard REST protocol

     

    Which gives this in the service image:

    Service Image

     

    I presume this is what was wanted?



  • 9.  Re: API based virtual service

    Posted Sep 30, 2016 05:34 AM

    Hi Rick.Brown KevinNg thanks for your answers.. Sorry the image I have attached may not contain multiple transactions but originally I did add several transaction into image once image is created.

     

    To answer Kevin questions,  " if I remove the Remove ?token=00000043547 from your base path in the model" 

     

    Then my endpoint/path looks like this 

     

    http://lisa_host:8001/web/CreditLimit 

     

    however my client front end based/java client call the actual API like this (GET  method)

     

    http://lisa_host:8001/web/CreditLimit?token=00000043547

     

    so, client will fail if I just mention http://lisa_host:8001/web/CreditLimit  with 404 not found error.. token will be also passed as part of resource url 

     

     

     



  • 10.  Re: API based virtual service

    Broadcom Employee
    Posted Sep 30, 2016 07:21 AM

    The way I created the stuff I screenshot in my previous response was simply by copying and adding to your data files, before doing another creation from RR pair.

     

    If this isn't what you are trying to do, and what I've shown isn't appropriate for your needs, then I am completely confused about your requirement.



  • 11.  Re: API based virtual service

    Posted Sep 30, 2016 08:44 AM

    Rick.Brown .. As I mentioned earlier .. My requirement is very simple.. 

     

    I have client who is calling a API which uses get method.. 

     

    The API endpoint/URI they call is https://server_host:443/web/CreditLimit?token=00000043547

     

    so I am trying to build virtual service for this... When I put these into RR pairs and create a virtual service using RR Pair, the virtual service built has the endpoint/base path only till /web/CreditLimit

     

    However when I deployed this VSM, my client not able to reach this endpoint because the endpoint looks like this LISA  https://server_host:443/web/CreditLimit whereas client trying to reach https://server_host:443/web/CreditLimit?token=00000043547..

     

    Client will send the token value dynamically based on the scenario and I need to make in LISA how to parameterize this token value in endpoint .. (not in VSI).. 

     



  • 12.  Re: API based virtual service

    Posted Sep 30, 2016 09:24 AM

    I believe some of the confusion is that the thread points out two scenarios rather than one.  These request scenarios are dealt with in different ways.  

     

    1) Your original post contained a value you wanted to parameterize in the URL.  Rick pointed out how to do this with the REST DPH.  In this scenario, the VSM parses the operation as GET /card_details/v1/debit-card/accounts/URLPARAM0/statuses.  The arg list is parsed to contain a URLPARAM0 with a value 5556664.  And the resulting base path is taken care of as well.  

     

    2) The other Use Case contained the parameter in a query string.  In this example, the query string value:

    ?token=00000043547 is parsed OOTB into the Arg List with a key of "token" and a value of "00000043547".  In this scenario, the REST DPH does not need to parameterize that value using the URLPARAM construct.  The base path that is generated in this scenario should not contain a reference to the query string.

     

    Both Rick and Kevin demonstrate this in their examples as well.



  • 13.  Re: API based virtual service

    Posted Sep 30, 2016 10:18 AM

    Yes , there are two threads in this.. Actually initially I have asked that question and then I had the other question which is second thread ..

     

    As per your answer to 2nd question.. 

     

     

    ?token=00000043547 is parsed OOTB into the Arg List with a key of "token" and a value of "00000043547".

    --> Yes, this is correct automatically when I create VS, LISA identifies this and covert token as key in VSI.

     

     In this scenario, the REST DPH does not need to parameterize that value using the URLPARAM construct.  The base path that is generated in this scenario should not contain a reference to the query string.

     

    -- > What I assume as per your comment is base path without query string .. 

     

    that will be look like /web/CreditLimit

     

    but client is invoking with URI like /web/CreditLimit?token=00000043547 

     

    so how do my client will establish connection with LISA base path, if the base path does not contain token as per your above comment ? 

     

    it will be like 404 not found error .. 



  • 14.  Re: API based virtual service
    Best Answer

    Posted Sep 30, 2016 04:27 PM

    I do not believe the /web/CreditLimit?token=xxxxx will result in a 404 at the HTTP layer.  The query string will be ignored in terms of HTTP's and the VSM's request matching against the base path of /web/CreditLimit.  The base path is CaSe sensitive though so ensure you have allowed for that.

     

    The query string should parse into arguments.  The VSI can/will error if the number of parms in the VSI mismatch against the incoming request's query string.  But, this error typically results in a "...Please expand the service..." message.

     

    As a test,

    - Set up your VSM to look watch with a base path of /web/CreditLimit.

    - Deploy the VSM

    - From a Browser, invoke the endpoint (http://<yourVseServer>:<listenPort>/web/CreditLimit?token=12345) 

    - Go into Inspection view for the service and you should see the operation display as GET /web/CreditLimit and the query string should parse into the Arg List as token = 12345.  This is the same as the graphics that Kevin and Rick show in the 6th and 7th posts, above. 

     

    If this behavior does not occur, please report back so we can try to help further.