reading the content of a file and send to a webservice by gatling


I want to use gatling for load testing a webservice

But there are some difficulties :

In my soap xml stream used for sending to the webservice, I have to include the content of a file (reading from disk)

Essentially, I have following ideas :

create a string variable certificate

read the content of my extern file line by line and make a concatenation of line data read in the string variable certificate

put the variable ${certificate} in my soap xml stream to send to the webservice (As I am new to gatling, this is just a idea, I do not know exactly how to to do that )

Therefore, I have tried to make my simulation program like that :

var certificate:String = “”;
val filename = “my_assertion.xml”
for (line ← Source.fromFile(filename).getLines()) {

http(“Appel WebService”)
.body(StringBody("""<soap:Envelope xmlns:soap=“”><soap:Header xmlns:wsa=“”>wsa:MessageID123456789</wsa:MessageID>wsa:Actionurn:test:1.0:test1</wsa:Action></soap:Header>soap:Bodytest:numTest1</test:numTest>test:zone_assertion${certificate}</test:test:zone_assertion></soap:Body></soap:Envelope>"""))

Of course, my simulation program does not compile

Do you think it is possible for gatling to do like above ?

If you have a better idea, can you help me ?



As a quick answer, do the following :


The long explanation :

“”"${foo}""" : that’s a normal string, foo will be taken from the Gatling session
s"""${foo}$${bar}""" : that’s a string interpolation, the ‘foo’ variable will be taken from the scala context and the ‘bar’ is using a double $ declaration so that it’s escaped and it will be taken from the Gatling session context


Hi Nicolas