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

Hi

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()) {
certificate.concat(line)
}

exec(
http(“Appel WebService”)
.post(“http://55.10.20.36:12000/MetierWS/TestWS”)
.headers(headers_2)
.body(StringBody("""<soap:Envelope xmlns:soap=“http://www.w3.org/2003/05/soap-envelope”><soap:Header xmlns:wsa=“http://www.w3.org/2005/08/addressing”>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>"""))
.check(status.is(200))
)

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 ?

Thanks

Nguyen

As a quick answer, do the following :

.body(StringBody(s"""<soap:Enve…

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

cheers
Nicolas

Hi Nicolas

Thanks

Nguyen