reading part of request body from a file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

reading part of request body from a file

Leor Amikam
Hello,

I am creating a set of soap/web service test cases where each case has an HTTP Request sampler.  There is common data in the request body used in the post.  For example:

<msg:Header>
                                <hdr:MsgID>L${__UUID()}</hdr:MsgID>
                                <hdr:MsgType>request</hdr:MsgType>
                                <hdr:MsgTimestamp>${__time(yyyy-MM-dd'T'hh:mm:ss)}</hdr:MsgTimestamp>
                                <hdr:MsgPriority>low</hdr:MsgPriority>
                              <hdr:MsgEncryption>false</hdr:MsgEncryption>
                                <hdr:MsgVersion>1.0</hdr:MsgVersion>
                                <hdr:MsgOperationType>xsynchronous</hdr:MsgOperationType>
                                <hdr:MsgOperationName>
                                                <hdr:Verb>GET</hdr:Verb>
                                                <hdr:Noun>Customer</hdr:Noun>
                                </hdr:MsgOperationName>
                                <hdr:MsgOperationUser>hcmuser</hdr:MsgOperationUser>
                </msg:Header>

What I am looking for, is a way to store these request fragments in a file, and load at runtime.  This is to avoid lots of redundant text between HTTP request calls.  Is there a way to do this?

Thanks
Leor

Notice:  This e-mail and any attachments are confidential and may contain legally privileged information and/or copyright material of Hansen Technologies Limited or third parties.  Copying, distributing, disclosing, commercialising or otherwise acting in reliance on this e-mail and any attachments is strictly prohibited unless you are the addressee of this e-mail and have written permission to do so.  If you have received this e-mail in error please delete this e-mail (including any copies and attachments) and contact Hansen Technologies Limited by return e-mail or by telephone on + 61 3 9840 3000.  Any views expressed in this e-mail are those of the individual sender and may not necessarily reflect the views of or be a commitment by the organisation, except where the individual sender has the authority and expressly states them to be so.
Reply | Threaded
Open this post in threaded view
|

Re: reading part of request body from a file

glinius@live.com
It is, take a look at  __FileToString() function
<https://jmeter.apache.org/usermanual/functions.html#__FileToString>   which
you can use directly in the HTTP Request sampler "Body Data" tab where it is
required to add this header.

Given you have nested functions inside the payload you will also need to
wrap it into  __eval() function
<https://jmeter.apache.org/usermanual/functions.html#__eval>   so they would
be evaluated in the runtime


> ${__eval(${__FileToString(/path/to/your/file,,)})}  

More information:  Here’s What to Do to Combine Multiple JMeter Variables
<https://www.blazemeter.com/blog/here%E2%80%99s-what-do-combine-multiple-jmeter-variables>  



--
Sent from: http://www.jmeter-archive.org/JMeter-User-f512775.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]