Service Virtualization

Expand all | Collapse all

How can I select a field from the request to be the token for conversation starter?

Legacy User

Legacy UserJul 25, 2017 02:27 PM

  • 1.  How can I select a field from the request to be the token for conversation starter?

    Posted Jul 18, 2017 11:18 AM

    I am trying to virtualize a rest service which has two transactions: 

    1- Post call with Customer Name and token

    2- Get call with the token to retrieve the data

    I was wondering if someone could help me and tell me how I can select the token from the first request and connect it to the second call. 

    Attachment(s)

    zip
    CALL-1-REQ.txt.zip   246 B 1 version
    zip
    CALL-1-RSP.txt.zip   255 B 1 version
    zip
    CALL-2-REQ.txt.zip   195 B 1 version
    zip
    CALL-2-RSP.txt.zip   312 B 1 version


  • 2.  Re: How can I select a field from the request to be the token for conversation starter?

    Posted Jul 18, 2017 02:13 PM

    Hello Ali, 

     

    While you are creating a VSI you can select the conversation starter and specify the token. Below the link to the documentation, please take a look at Conversation Starter Transactions and Token Identification area:

    HTTP/S Transport Protocol - DevTest Solutions - 10.1 - CA Technologies Documentation 

     

    You can also use the Request Data Manager DPH to set a session key.

    Request Data Manager Data Protocol - DevTest Solutions - 10.1 - CA Technologies Documentation 

     

    VSM and VSI "kioskV5" under the Examples project is an example of stateful service.

     

    Hope it helps.

     

    Heloisa



  • 3.  Re: How can I select a field from the request to be the token for conversation starter?

    Posted Jul 18, 2017 02:37 PM

    Hi Maria,
    Thanks for your response. I checked those links but I couldn't figure it out. Let me give you more details. In the first request (POST), there are two fields: CustomerName and RequestID. The response to the POST call is static ("Request Received"). The second call (GET) only has one argument "RequestID" and the response has customer information of "CustomerName". I have two challenges to virtualize this service:
    1- RequestID is a random number that requester system generates at run time, so I can't have the right value for it in my request/response pairs when I am creating the image.

    2- The second call only has the RequestID. So, I should use RequestID to get the name from the first call and return the information for that name. Since RequestID is only part of the request, I can't access it in the "Token Identification Area"

     

    Thanks for your help.

    Ali



  • 4.  Re: How can I select a field from the request to be the token for conversation starter?

    Posted Jul 20, 2017 11:52 AM

    Ali, add the "Request Data Manager" data protocol when you do the recording.  There is an option to copy a request argument as the "LISA Session Key".  I believe this will do what you need.



  • 5.  Re: How can I select a field from the request to be the token for conversation starter?

    Posted Jul 20, 2017 02:58 PM

    Thanks Robert. I defined a new action to copy the RequestID to LISA Session Key. Now I can see that both calls are part of the same conversation session but I can't access the CustomerName argument from the first call in the matching script of the second call.



  • 6.  Re: How can I select a field from the request to be the token for conversation starter?

    Posted Jul 20, 2017 03:54 PM

    Check the "Magic String" checkbox in the service image editor next to the customer name argument, then save and redeploy.



  • 7.  Re: How can I select a field from the request to be the token for conversation starter?

    Posted Jul 20, 2017 04:46 PM

    Robert, I did mark the name as "Magic String" but it didn't work. I have attached RRpairs for a conversation. Hopefully these files can clarify the issue. Each customer has a different address. When I am creating the VSI, I don't know what will be the RequestID on the requests for each customer so the values in my RRpairs are dummy. In order to send the right response to the second call, I need to know the customer name for that RequestID from the first call. I thought using the RequestID as the session key can help me to access the CustomerName on the first call, but it doesn't work.



  • 8.  Re: How can I select a field from the request to be the token for conversation starter?
    Best Answer

    Posted Jul 24, 2017 05:11 PM

    Ali,

    Wondering if the "Name in Session" field in the VSI under Request Data would help you.

    You can try giving a name under the "Name in Session" field in the first transaction and then use this name in the next transaction - using double curly braces.



  • 9.  Re: How can I select a field from the request to be the token for conversation starter?

    Posted Jul 25, 2017 02:40 PM

    Thanks Maria. Your suggestion was really helpful. Is there anyway that I can use the same "Match Script" for all transactions in the second call or I should add the same script to all of them?



  • 10.  Re: How can I select a field from the request to be the token for conversation starter?

    Posted Jul 27, 2017 10:45 AM

    Ali,

     

    You will need to add the match script to the transactions you want, but if you are using the same match script in every transaction, maybe it will be a good idea to have that script in the VSM, before the VS Image Response selection step.

     

    Heloisa



  • 11.  Re: How can I select a field from the request to be the token for conversation starter?

    Posted Aug 01, 2017 03:36 PM

    I put an "Execute script" node before my "VS Image Response Selection" node and I added the script there. When I test it, it doesn't work (can't find vse request). How should I add the script on the model properly?

    Thanks for your help.



  • 12.  Re: How can I select a field from the request to be the token for conversation starter?

    Posted Aug 01, 2017 03:43 PM

    You'd have to add the match script onto each response in the service image.  There's no way to globally apply it.

     

    Match scripts execute slowly and I don't generally recommend them.  Use a different approach if you can, for instance a Data Protocol to reformat the incoming request.



  • 13.  Re: How can I select a field from the request to be the token for conversation starter?

    Posted Jul 24, 2017 11:01 PM

    Is it necessary to connect the both together?

     

    The first call will only need the Virtual Service to respond with an acknowledgement. This is straightforward and done.

     

    The second call will need the Virtual Service to respond according to the request ID, this is having issue? Have you tried using Data-Driven Virtual Service? Since the the request token is sent by the upstream system, the Virtual Service should only perform up to just matching and responding to the request.

     

    Create Data-Driven Virtual Services - DevTest Solutions - 10.0 - CA Technologies Documentation 



  • 14.  Re: How can I select a field from the request to be the token for conversation starter?

    Posted Jul 25, 2017 02:27 PM

    Yes, we need to connect them together.