Jump to content
WAPT Forum
Sign in to follow this  
Guest Joel P

How to POST raw data from file?

Recommended Posts

Guest Joel P

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

Share this post


Link to post
Share on other sites
Guest Sreenadh OG

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

 

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.loadtestingtool.com/forum/builds/WAPTPro2.0.zip

 

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites
Guest Sreenadh OG

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

 

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

 

Share this post


Link to post
Share on other sites
Guest Sreenadh OG

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). :)

Regards,

Sreenadh

 

Yes, you can use all that Windows Scripting Host can do.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×