Modifying Scripts

Parameterize scripts of SessionID

Parameterize scripts of SessionID:

  1. Use the keyword "servlet" to search in the scripts. Find the function that has the first occurrence of both the "servlet" keyword and the "BodyBinary" parameter, and then add the following script in front of it, so as to capture the current SessionID.

    web_reg_save_param("SessionID","LB=ID =","RB=\r\n",LAST);
  2. Search all the remaining "servlet" statements, and modify the parameters starting with "Body=" in the following way:

    Find the location of "session_id =", and replace the recorded value of SessionID with the character string "{SessionID}".

    Example in PowerServer 2016 and later versions:

    Replace

    "Body=<?xml version=\"1.0\" encoding=\"utf-8\"?><data><header type=\"193\" version=\"35\" session_id=\"2011743809\" /> 

    with

    "Body=<?xml version=\"1.0\" encoding=\"utf-8\"?><data><header type=\"193\" version=\"35\" session_id=\"{SessionID}\" /> 

    Example in PowerServer 2015 and earlier versions:

    Replace

    "session_id = -318005152\r\n" 

    with

    "session_id = {SessionID}\r\n"

    The following block ({SessionID} in "session_id = {SessionID}\r\n") is an example after changed.

    web_custom_request("appeon.weblibrary.AXDispatcher_6",
    "URL=http://172.17.1.108:8080/servlet/appeon.weblibrary.AXDispatcher",
    "Method=POST",
    "Resource=1",
    "Referer=",
    "EncType=",
    "Body="
    "\\x1F\\x8B\\x08\\x00\\x00\\x00\\x00\\x00\\x00\\x0B"
    "ST"
    "\\x16"
    "b0a0"
    "\\x06"
    "b"
    "\\x0B\\x06"
    "K"
    "\\x06"
    "C"
    "\\x06"
    "3"
    "\\x06"
    "#"
    "\\x06"
    "S"
    "\\x06"
    "1"
    "\\x86\\x00"
    "†T"
    "\\x86"
    "\""
    "\\x86"
    "4†| ™ËÈÇ"
    "\\x90\\x0C\\x14\\x01\\x01"
    "1 fb"
    "\\x00\\x00\\x12\\x02"
    "½8"
    "\\x00\\x00\\x00"
    "--------------------appeon data\r\n"
    "Name = Kill Session\r\n"
    "session_id = {SessionID}\r\n"
    "--------------------appeon data\r\n"
    "D"
    "\\x00\\x00\\x00"
    ,
    LAST);

Parameterize request header

Check the scripts and make sure each request to the axdispatcher.aspx page contains the "pt" and "protocolMode" parameters in its header. For example,

web_add_header("pt","1090");
web_add_header("protocolMode","xml");
web_custom_request("axdispatcher.aspx_1",
  "URL=http://192.0.1.1/servlet/axdispatcher.aspx",
  "Method=POST",
  "Resource=0",
  "RecContentType=text/html",
  "Referer=",
  "Snapshot=t34.inf",
  "Mode=HTTP",
  "EncType=",
  "Body=<?xml version=\"1.0\" encoding=\"utf-8\"?><data><header type=\"192\" version=\"35\" session_id=\"{SessionID}\" />
  <transobject name=\"sqlca\" dbms_id=\"0\" autocommit_mode=\"0\" sql_code=\"0\" sql_dbcode=\"0\" sql_nrow=\"0\" sql_errortext=\"\" 
  server_name=\"192.0.2.1\" database=\"appeon\"  log_id=\"appeon\" db_password=\"\" user_password=\"appeon\" user_id=\"\" 
  identity=\"0\" cache_name=\"appeon\" commiton_disconnect=\"-1\" catalog_owner=\"58633936\" lock_level=\"65176744\" 
  capital_identifier=\"0\" associate_tablecolumn=\"0\" driver_id=\"10\" trimspace=\"-1\" />
  <body><sql type=\"1\"><value><![CDATA[@@SQL_6_u_mdi_fxs]]></value></sql><parameters count=\"1\">
  <parameter name=\"ESQL_1\" isnull=\"false\" datatype=\"1\" inouttype=\"1\">DEM</parameter></parameters></body></data>",
LAST);

To add the "pt" parameter:

Step 1: Search for the scripts that request the axdispatcher.aspx page.

For example, web_custom_request("axdispatcher.aspx",……); indicates the first request to the axdispatcher.aspx page;

web_custom_request("axdispatcher.aspx_1",……); indicates the second request to the axdispatcher.aspx page.

Step 2: In the PowerServer log file generated via debug mode in AEM, search for the header-pt information according to the sequence of the requests, and then convert its value from binary to decimal.

For example, binary "0000010001000010" can convert to decimal "1090".

Figure 15. header-pt information in the log file

header-pt information in the log file

Step 3: Add the "pt" parameter and the decimal value to the scripts before the request starts.

For example, web_add_header("pt","1090");

To add the "protocolMode" parameter:

If the body of the request to the axdispatcher.aspx page is an XML string, add the "protocolMode" parameter to the scripts before the request starts.

For example, web_add_header("protocolMode","xml");

Parameterization of DataWindow SQL statements

  1. The recorded DataWindow SQL statements are as follows:

    "UpDateSQL_1 = update \"PERF_TEST1\" set \"depid\" = 
    1,\"code\" = 'modify1',\"name\" = 'modify1',\"born\" = '2006-09-04 
    14:35:12.843',\"age\" = 1,\"salary\" = 1 where \"id\" = 0;update 
    \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 'modify1',\"name\" = 
    'modify1',\"born\" = '2006-09-04 14:35:12.843',\"age\" = 
    1,\"salary\" = 1 where \"id\" = 1;update \"PERF_TEST1\" set 
    \"depid\" = 1,\"code\" = 'modify1',\"name\" = 'modify1',\"born\" = 
    '2006-09-04 14:35:12.843',\"age\" = 1,\"salary\" = 1 where \"id\" 
    = 2;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    'modify1',\"name\" = 'modify1',\"born\" = '2006-09-04 
    14:35:12.843',\"age\" = 1,\"salary\" = 1 where \"id\" = 3;update 
    \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 'modify1',\"name\" 
    = 'modify1',\"born\" = '2006-09-04 14:35:12.843',\"age\" = 
    1,\"salary\" = 1 where \"id\" = 4;update \"PERF_TEST1\" set 
    \"depid\" = 1,\"code\" = 'modify1',\"name\" = 'modify1',\"born\" = 
    '2006-09-04 14:35:12.859',\"age\" = 1,\"salary\" = 1 where \"id\" 
    = 5;update \"PERF_TEST1\" set \"depi" 
    "d\" = 1,\"code\" = 'modify1',\"name\" = 
    'modify1',\"born\" = '2006-09-04 14:35:12.859',\"age\" = 
    1,\"salary\" = 1 where \"id\" = 6;update \"PERF_TEST1\" set 
    \"depid\" = 1,\"code\" = 'modify1',\"name\" = 'modify1',\"born\" = 
    '2006-09-04 14:35:12.859',\"age\" = 1,\"salary\" = 1 where \"id\" 
    = 7;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    'modify1',\"name\" = 'modify1',\"born\" = '2006-09-04 
    14:35:12.859',\"age\" = 1,\"salary\" = 1 where \"id\" = 8;update 
    \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 'modify1',\"name\" = 
    'modify1',\"born\" = '2006-09-04 14:35:12.859',\"age\" = 
    1,\"salary\" = 1 where \"id\" = 9\r\n"
    1. To make the field value change every time the same user executes it, you need to parameterize the constant after the field: "modify1" in the above example.

    2. To ensure that different virtual users modify different records, you need to parameterize the id value after the "Where" keyword.

    For these purposes, at least two parameters should be set: "Modified" and "ID".

    To parameterize fields of the number type and the data type, it is also necessary to set the new parameters.

    In this example, the type of parameter "Modified" is iteration number, and the type of parameter "id" is UserID.

  2. In the scripts, for most field values, you must perform the following two replacements in the DataWindow SQL statements.

    1. Replace "modify1" with "{modified}"

    2. Replace "where \"id\" = " (Note: In this example, the last character included in the quotation mark must be a space) with "where \"id\" = {id}"

    If the text to be replaced is split and displayed in two lines, for example, "modify1" is displayed as "modif" and "y1" in two separated lines, you need to manually modify or programmatically replace it, otherwise transaction failures will occur when there are many concurrent user access.

    Make sure that every SQL statement is correctly replaced.

    ………………………………,\"col8\" = '{modified}',\"col9\" = 'modif"
    "y1',\"col10\" = 'modify1' where \"id\" = {id}06;………………………
  3. The parameterized SQL statements are as follows:

    "UpDateSQL_1 = update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.859',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}0;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.859',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}1;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.859',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}2;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.875',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}3;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.875',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}4;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.875',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}5;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.875',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}6;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.875',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}7;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.890',\"age\" = 1,\"salary\" = 1 where \"id\" = 
    {id}8;update \"PERF_TEST1\" set \"depid\" = 1,\"code\" = 
    '{modified}',\"name\" = '{modified}',\"born\" = '2006-09-04 
    11:25:12.890',\"age\" = 1,\"salary\" = 1 where \"id\" = {id}9\r\n"
  4. When playing back the scripts after replacement, the DataWindow SQL statements executed are as follows:

    UpDateSQL_1 = update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.859',"age" = 1,"salary" = 1 where "id" = 
    10;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.859',"age" = 1,"salary" = 1 where "id" = 
    11;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.859',"age" = 1,"salary" = 1 where "id" = 
    12;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    13;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    14;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    15;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    16;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    17;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.890',"age" = 1,"salary" = 1 where "id" = 
    18;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify1',"name" = 'modify1',"born" = '2006-09-04 
    11:25:12.890',"age" = 1,"salary" = 1 where "id" = 19
  5. In the iterative operations, the DataWindow SQL statements executed at the third time are as follows:

    UpDateSQL_1 = update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.859',"age" = 1,"salary" = 1 where "id" = 
    10;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.859',"age" = 1,"salary" = 1 where "id" = 
    11;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.859',"age" = 1,"salary" = 1 where "id" = 
    12;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    13;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    14;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    15;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    16;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.875',"age" = 1,"salary" = 1 where "id" = 
    17;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.890',"age" = 1,"salary" = 1 where "id" = 
    18;update "PERF_TEST1" set "depid" = 1,"code" = 
    'modify3',"name" = 'modify3',"born" = '2006-09-04 
    11:25:12.890',"age" = 1,"salary" = 1 where "id" = 19

    In this way, the value changes every time the same user executes an Update operation.

Parameterization of Embedded SQL statements

To parameterize the value in the embedded SQL statement, you will have to define the value as a variable.

For example, the following script cannot be parameterized.

select a from table where c = ‘1’;

You will have to modify the script as below, in order to parameterize the value:

int ic
ic = 1
select a from table where c= :ic

Additional steps for the Update operation

For the Update operation, the script parameterization should meet the following three requirements:

  1. Parameterization of SessionID (which has already been described in Parameterize scripts of SessionID);

  2. Parameterization of SQL statements (which will be described in Parameterization of DataWindow SQL statements and in Parameterization of Embedded SQL statements);

  3. Add the Commit request to the end of each Update request, that is, move the Commit request in the recorded scripts from end.c to action.c.