Custom Request To web_submit_data to upload a file

2,126 views
Skip to first unread message

Manny Yamzon

unread,
Sep 20, 2010, 12:51:40 AM9/20/10
to LR-Loa...@googlegroups.com
Hi Guys,
    I hope everyone is doing fine today and I thank in advance who can possibly help me with any input regarding this issue that I have. Basically, this custom request below works fine on a small file, the body gets so large for a large file where I can't get a successful run. So I was trying to transform this into a web_submit_data (please see below, also a small file) but it looks like i am not parsing the Body properly (as per the required itemdata), can you spot what I am missing here to make the request work? Thanks in advance, Manny
 
 
web_custom_request("bl_11", 
  "URL=https://test.abc.com/test_app/bl",
  "Method=POST",
  "Resource=0",
  "RecContentType=text/html", 
  "Snapshot=t20.inf",
  "Mode=HTML", 
  "EncType=multipart/form-data; boundary=---------------------------7da1882a807e8",
  "Body=-----------------------------7da1882a807e8\r\nContent-Disposition: form-data; name=\"a\"\r\n\r\nproduct_upload\r\n-----------------------------7da1882a807e8\r\nContent-Disposition: form-data; name=\"t\"\r\n\r\nproduct_upload_save\r\n-----------------------------7da1882a807e8\r\nContent-Disposition: form-data; name=\"submissionid\"\r\n\r\n\r\n-----------------------------7da1882a807e8\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\nRecording for TXT doc\r\n"
  "-----------------------------7da1882a807e8\r\nContent-Disposition: form-data; name=\"div\"\r\n\r\nproduct_upload_ebook\r\n-----------------------------7da1882a807e8\r\nContent-Disposition: form-data; name=\"book\"; filename=\"collate.txt\"\r\nContent-Type: text/plain\r\n\r\n[Collate Recovery]\r\nScenario=\\\\injperfeng01\\d$\\LoadTests\\HP\\Scenario\\Cart2_Account_Orderstatus.lrs\r\n\r\n-----------------------------7da1882a807e8\r\nContent-Disposition: form-data; name=\"fakeinputbox_ebook\"\r\n\r"
  "\nC:\\fakepath\\collate.txt\r\n-----------------------------7da1882a807e8--",
  LAST);
 
  web_submit_data("Upload",
   "Action=https://test.abc.com/pubit_app/bl", 
   "Method=POST",
   "RecContentType=text/html", 
   "Snapshot=t15.inf",
   "Mode=HTML",
   ITEMDATA,
   "name=a", "Value=product_upload", ENDITEM,
   "name=t", "Value=nproduct_upload_save", ENDITEM,
   "name=submissionid", "Value={SubID}", ENDITEM,
   "name=title", "Value=PerfTitle", ENDITEM,
   "name=product_upload_ebook", "Value=book", ENDITEM,
   "name=filename", "Value=collate.txt", ENDITEM,
   "name=fakeinputbox_ebook", "Value=C:\\\\collate.txt", ENDITEM,
   LAST);

Venkat P

unread,
Sep 20, 2010, 12:59:28 AM9/20/10
to lr-loa...@googlegroups.com
2 "\"s should be enough - not four... and I assume that submission id is a properly correlated value ?(or a correctly set up one atleast?)

--
You received this message because you are subscribed to the Google "LoadRunner" group.
To post to this group, send email to LR-Loa...@googlegroups.com
To unsubscribe from this group, send email to
LR-LoadRunne...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/LR-LoadRunner?hl=en

chaitanya bhatt

unread,
Sep 20, 2010, 2:23:47 AM9/20/10
to lr-loa...@googlegroups.com
The path of the file that you have mentioned is correct. But I guess you have missed adding the "File" attribute for the fakeinpubox_ebook field.  Change the last n-v pair statement to: "name=fakeinputbox_ebook", "Value=C:\\\\collate.txt", "File=Yes".
And I also think you have missed including the "push" button's name-value data in the web_submit_data function(example: "Name=submit", "Value=Submit) .
 
Posting the actual html form in this forum would help us suggest you the exact web_submit_data parameter list.
-Chaitanya M Bhatt

--

Manny

unread,
Sep 20, 2010, 8:00:15 AM9/20/10
to lr-loa...@googlegroups.com, lr-loa...@googlegroups.com
Good points and thanks for sparing some time on looking onto this guys, I'll definitely try it as soon as i get to work in a few. 


Manny Yamzon

unread,
Sep 20, 2010, 4:19:55 PM9/20/10
to lr-loa...@googlegroups.com
I have talked to the developer as well, just to confirm the required fields to send, I added the "File=Yes" and it did already worked.
The weird part is it still worked with the 4 slashes "\\\\", hey, as long as it is doing its job right... verified that the file was uploaded properly.  Thanks CB & Venkat!

chaitanya bhatt

unread,
Sep 20, 2010, 10:07:02 PM9/20/10
to lr-loa...@googlegroups.com
@Manny: You are welcome!

-Chaitanya M Bhatt

Manny Yamzon

unread,
Sep 23, 2010, 10:10:12 AM9/23/10
to lr-loa...@googlegroups.com
CB, I got a follow up on this, not sure if I need to make a new email tread. basically, the script works perfectly fine (upload), I can see the DB update, the destination folder was also updated as well as the UI :).

now the new problem is, If I run on controller with 1 vuser, it works just as you are in vugen, although if I put more that one user, nothing is getting uploaded.

What do you think of that?

Thanks,
Manny

chaitanya bhatt

unread,
Sep 23, 2010, 10:40:17 AM9/23/10
to lr-loa...@googlegroups.com
Generally there are two ways of dumping user uploaded files into the server.
1. Application server validates the file format and size and then accepts the uploaded file and stores it in a specific directory.

2. Validates the file and then uploads the file into a database(example mysql or oracle)

Type-1: The first method of file reception is very basic, yet very commonly practiced. There is a catch when you emulate multiple vusers, which is: Server won't receive files if there is another file already present with the same name. So, you will have to keep different copies of the file with different names at the client side.

Type-2: The 2nd method of file reception is generally user specific. Meaning, as long as the same user is not uploading the same file, it will not restrict users from uploading duplicate copies of the file.

My guess here is that your app server is of Type-1, so, create multiple copies of the file, give a unique name to each copy of the file and parametrize the name set in LR and then try running it with multiple Vus in the controller.

Manny Yamzon

unread,
Sep 23, 2010, 1:41:27 PM9/23/10
to lr-loa...@googlegroups.com
I am positive that this app is doing both, because the way I check a successful run after running in vugen is by checking if the physical destination folder contains the exact file and that the database has been updated with the file location, name, timestamp & etc.

An in this case I should be doung both types right?

chaitanya bhatt

unread,
Sep 24, 2010, 12:46:17 AM9/24/10
to lr-loa...@googlegroups.com
Yes. I guess, you should take care of both the scenarios in your case.
 
-Chaitanya M Bhatt

Manny

unread,
Sep 28, 2010, 7:40:58 AM9/28/10
to lr-loa...@googlegroups.com, lr-loa...@googlegroups.com
CB, i have applied both and been busy running the tests, all are working perfectly fine, thanks for all your help.!!!


Reply all
Reply to author
Forward
0 new messages