Jump to content


How to POST raw data from file?


  • Please log in to reply
7 replies to this topic

#1 Guest_Joel P_*

Guest_Joel P_*
  • Guests

Posted 19 March 2010 - 04:06 PM

We are evaluating WAPT to load test a REST web service. A key requirement is to be able to POST large XML, JSON, etc. payloads. I see that I can paste text directly into the "POST raw data" field, but our payloads are too large and get truncated when I do this.

It seems like I *should* be able to use the $File and perhaps $Var functions to request that I want a payload to be loaded from a file, but $File(application/xml, 'pathtofile') just results in that string being POSTed, which of course is rejected as an invalid request, and $Var($File(application/xml, 'pathtofile')) results in no payload at all. If I save $File(application/xml, 'pathtofile') to the variable 'myPayload' after the previous request, $Var(myPayload) also results in the raw string $File(application/xml, 'pathtofile') being POSTed, which of course is also not good.

Can someone please explain to me either a) what I'm doing something wrong, or b) confirmation that WAPT lacks this ability, which would be a deal-killer for us.

To be clear, if my file is named "foo.xml", and contains the XML <foo>12345</foo>, I want WAPT to produce a request like the following:

POST /myapp/whatever HTTP/1.1
Content-Type: application/xml
...
Connection: Keep-Alive

<foo>12345</foo>

===================
Currently the closest I can get is:

POST /myapp/whatever HTTP/1.1
Content-Type: application/xml
...
Connection: Keep-Alive

$File(application/xml, 'foo.xml')
===================

Any help would be greatly appreciated.

-joel

#2 Sergei Leonov

Sergei Leonov

    Advanced Member

  • Administrators
  • PipPipPip
  • 662 posts

Posted 23 March 2010 - 12:18 PM

It isn't possible in the current version. In the new version of WAPT Pro you can use JavaScript for loading XML from file. You can download beta from http://www.loadtesti.../WAPTPro2.0.zip
Sergei Leonov
WAPT Project Manager
SoftLogica LLC

Office: +7-383-335-6692
Toll-free: 1-888-364-6797 (for US only)
Time zone GMT +6, EST +11
E-mail: support@loadtestingtool.com
http://www.loadtestingtool.com

#3 Guest_Sreenadh OG_*

Guest_Sreenadh OG_*
  • Guests

Posted 29 March 2010 - 02:45 PM

Dear Sergei,
//In the new version of WAPT Pro you can use JavaScript for loading XML from file.//
Do you mean to say that I can use WAPT Javascript to read from my local hard disk? Can you provide with a code example and clarify please?
Regards,
Sreenadh

QUOTE (Sergei Leonov @ Mar 23 2010, 05:48 PM) <{POST_SNAPBACK}>
It isn't possible in the current version. In the new version of WAPT Pro you can use JavaScript for loading XML from file. You can download beta from http://www.loadtesti.../WAPTPro2.0.zip



#4 Sergei Leonov

Sergei Leonov

    Advanced Member

  • Administrators
  • PipPipPip
  • 662 posts

Posted 30 March 2010 - 12:14 PM

Yes, you can read a data from a file and initialize a variable.
For example, you can place the file to a network share, give an access to the file for Everyone (for remote Load Agents) and use following JavaScript code:

var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso.OpenTextFile("\\\\Server\\Share\\filename.txt", 1, false);

context.variable("XML") = file.ReadAll();//You should create "XML" variable in advance

Sergei Leonov
WAPT Project Manager
SoftLogica LLC

Office: +7-383-335-6692
Toll-free: 1-888-364-6797 (for US only)
Time zone GMT +6, EST +11
E-mail: support@loadtestingtool.com
http://www.loadtestingtool.com

#5 Guest_Sreenadh OG_*

Guest_Sreenadh OG_*
  • Guests

Posted 30 March 2010 - 01:08 PM

Dear Sergei,
Do you want to say that, I can use the full power of WSH JScript coding from within WAPT? Or does WAPT Javascript provides limited features only?
Regards,
Sreenadh

QUOTE (Sergei Leonov @ Mar 30 2010, 05:44 PM) <{POST_SNAPBACK}>
Yes, you can read a data from a file and initialize a variable.
For example, you can place the file to a network share, give an access to the file for Everyone (for remote Load Agents) and use following JavaScript code:

var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso.OpenTextFile("\\\\Server\\Share\\filename.txt", 1, false);

context.variable("XML") = file.ReadAll();//You should create "XML" variable in advance



#6 Sergei Leonov

Sergei Leonov

    Advanced Member

  • Administrators
  • PipPipPip
  • 662 posts

Posted 31 March 2010 - 06:09 AM

Yes, you can use all that Windows Scripting Host can do.
Sergei Leonov
WAPT Project Manager
SoftLogica LLC

Office: +7-383-335-6692
Toll-free: 1-888-364-6797 (for US only)
Time zone GMT +6, EST +11
E-mail: support@loadtestingtool.com
http://www.loadtestingtool.com

#7 Guest_Sreenadh OG_*

Guest_Sreenadh OG_*
  • Guests

Posted 06 April 2010 - 11:13 AM

Dear Sergei,
Great! It would be great if you include a WSH JScript tutorial along with Wapt Pro 2.0 help. Just a suggestion (especially considering the fact that there is only very little info on the same available in net). smile.gif
Regards,
Sreenadh

QUOTE (Sergei Leonov @ Mar 31 2010, 11:39 AM) <{POST_SNAPBACK}>
Yes, you can use all that Windows Scripting Host can do.



#8 Sergei Leonov

Sergei Leonov

    Advanced Member

  • Administrators
  • PipPipPip
  • 662 posts

Posted 07 April 2010 - 09:31 AM

We think about it.
Sergei Leonov
WAPT Project Manager
SoftLogica LLC

Office: +7-383-335-6692
Toll-free: 1-888-364-6797 (for US only)
Time zone GMT +6, EST +11
E-mail: support@loadtestingtool.com
http://www.loadtestingtool.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users