Session ID ("sessionid") is different every time you run an installable cloud app. Obviously, since the execution of the recorded script depends upon the session ID returned by the server, it is necessary to catch the proper "sessionid" from the CreateSession server response and then attach it to the subsequent requests. That is, correlating the session ID in the script for successful replay.
-
Add scripts in the CreateSession for capturing the session ID and assign it to a parameter.
A CreateSession request looks like the following:
web_custom_request("CreateSession", "URL=http://172.16.9.79:5099/api/ServerApi/CreateSession", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Snapshot=t5.inf", "Mode=HTTP", "EncType=application/json;charset=UTF-8", "Body={\"header\":[\"2.0\",\"28BAE768-E68A-4c0d-B598-2AD639702CDA\",31,\"psapi4loadrunner_cloud\",\"Psapi4loadrunner_cloud\",\"\"],\"content\":{\"securestring\": \"eyJ0aW1lc3RhbXAiOjE2NTk5Mzk5NDEsInBheWxvYWQiOiJLR0NYdGE2S2pwYnRsTUJlRXVub0JWS1V6dVN5cXpQM3VURStTaHA1ZXJxQmVIU1phUUYra1lQM3FLQ2ZPTHAvaHRpQXpBQUJ2Q3hIM0gwdVNJU2w5UT09Iiwic2lnbmF0dXJlIjoiWlJxZ05SaUEwSUpKWkdPTmR2OFhoWVpsZFVxQnljZWJXTjJheWFHbXdQL29sWkNOKy8zamtsS2FlT3RsbDBoYlVVb2ltVnlCT3J0cUtWNWhxdjhpckE9PSJ9\"}}", LAST);
You need to add the following code above the CreateSession request:
-
Add a web_set_max_html_param_len function to be the first line in the script file. It would set the maximum length of the HTML string which LoadRunner can retrieve:
web_set_max_html_param_len("262144");
-
Add a web_reg_save_param function above CreateRequest to capture the session ID and assign it to the parameter "gs_SessionID".
web_reg_save_param("gs_SessionID","LB=\"sessionid\":\"","RB=\"},\"graceperiod","Search=Body",LAST);
-
-
Replace the session ID with the parameter every time it occurs.
-
Identify the session ID that needs to be correlated. You may do a global search in the script for "session" which is followed by the session ID.
-
Replace every occurrence of the session ID with the parameter <gs_SessionID>.
Taking the ConnectAndCreateTransaction request as an example. The following is the original request (notice that the session ID is an encrypted string before it is correlated with a variable):
web_custom_request("ConnectAndCreateTransaction", "URL=http://172.16.9.79:5099/api/ServerApi/ConnectAndCreateTransaction", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Snapshot=t7.inf", "Mode=HTTP", "EncType=application/json;charset=UTF-8", "Body={\"header\":[\"2.0\",7,\"psapi4loadrunner_cloud\",\"Psapi4loadrunner_cloud\",\"" "eyJ0aW1lc3RhbXAiOjE2NTk5Mzk5NDUsInBheWxvYWQiOiI4dTdSaVd5RE95alhMSmx0a0ZmRm9BamVqNXhQSy9aWTl3UFhUVGVjVkgxODBQNGptMzhzYnRmYkRwUnN6ZzhaMTcyVzBBbGU2S1hzN2pRTU1lcjZOTm1lZ1pVM01rcjZFQ3QxTXBQa1pTK2dZaC9zSXc0eC9oeUx4VzN2c2dreHh2SzdReDgxZFBuUm5ZbzF0bHl5cTJtTkoxNi84ZzV0Z3VjbUxBejdoNFdVcWRUNTFvWkhwUmsrTUVxOXg0enQiLCJzaWduYXR1cmUiOiJGR0ViVTBtdWNsZjlrYUVYYnI4Q0ZKaklCWFdza200VnVuNkpyWU0wd1I5bnE4MXQrTlRUa2xSVEQ2RG1uamFZQVdHYTYyaTVGeGlwRm8yVTI4ODNPdz09In0=\",\"\",\"sqlca\"],\"content\":{\"cachegroup\":\"\",\"" "cachename\":\"\",\"transactionname\":\"sqlca\",\"params\":\"eyJ0aW1lc3RhbXAiOjE2NTk5Mzk5NDUsInBheWxvYWQiOiJpSERnL3Y1Z2U1b1d2TlRJRnYzdExnQTY1Q0o1S0FPczFXNjBqdFdtbURqUlJoK2EwTVdkeW1OOEkzd1RIYlBUZWdETXphL3JLZXlHMndac1ZhNEY3aVE0d3JubzdkWVhwVnAzcWdpVGlRUVVkczR6d3lNSW9VYU43YUxwL1FYcyIsInNpZ25hdHVyZSI6IlVhd3JvTUxzMWJVN0hFaDhvMVljMkJvTnFpb2k0ZUExeFJ2L0JtYm1GZTBZTDFLNjFpTVNqTHZrZHZEUExjMC9UTGJQMnIvbVo5R2sxUi9CMmFaRFd3PT0ifQ==\"}}", LAST);
After replacing the occurrence of the session ID with the parameter <gs_SessionID>, the script will look like the following:
web_custom_request("ConnectAndCreateTransaction", "URL=http://172.16.9.79:5099/api/ServerApi/ConnectAndCreateTransaction", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Snapshot=t65.inf", "Mode=HTTP", "EncType=application/json;charset=UTF-8", "Body={\"header\":[\"2.0\",7,\"psapi4loadrunner_cloud\",\"Psapi4loadrunner_cloud\",\"" "<gs_SessionID>\",\"\",\"sqlca\"],\"content\":{\"cachegroup\":\"\",\"" "cachename\":\"\",\"transactionname\":\"sqlca\",\"params\":\"eyJ0aW1lc3RhbXAiOjE2NTk4ODM1NjYsInBheWxvYWQiOiJidWx1VkxDdWJMa1NCWUpkejZuUVMvdU5KdFJyT1gyeXU2RC8yRjcxdlNRRllvVlZQQitiYS9qMGhVQkgwY3dEblo2d3Y3N2ZZVUl3VEF0OWlGc2NaZEl5TGg2M3MrOXc4Q3h5bWZRaTJFaDdaNGZnd0dWUmdabkdUUGFaQWY2MSIsInNpZ25hdHVyZSI6InM4L0VKQXhTdWZmckt3M3FsVGxzcTNIQXdmek5MLzZaM3NjOXdlUDcxM1FScTdoUFRpbmZaVmRTby94T3kzUFNWVldBUUUvMzdRcHg2ejBsTEZLajVBPT0ifQ==\"}}", LAST);
-