Using Gatling for WebService testing and ELFile

Hi,
I want to test a webservice using Gatling, and I heard that one could i.e. make the request from SoapUI and then feed it in With something called ELFile.
Does anybody have a working example of this?

Thanks in advance.

Magnus

http://gatling.io/docs/2.0.0-RC4/http/http_request.html?highlight=elfilebody#request-body

Ok thanks, but given that I have i.e. a soapui web service test that has a request like:

<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:web=“http://www.webserviceX.NET/”>
soapenv:Header/
soapenv:Body
web:ChangeMetricWeightUnit
web:MetricWeightValue30</web:MetricWeightValue>
web:fromMetricWeightUnitkilogram</web:fromMetricWeightUnit>
web:toMetricWeightUnitgram</web:toMetricWeightUnit>
</web:ChangeMetricWeightUnit>
</soapenv:Body>
</soapenv:Envelope>

and a endpoint like: http://www.webservicex.net/convertMetricWeight.asmx

This is a Public (working) webservice.

How could I add this With ELFile?

In IntelliJ I assume I would create a .xml file containing soapenv:Envelope…</soapenv:Envelope>

and in my simulation say something like:

import io.gatling.core.Predef._
import io.gatling.http.Predef._
/**

Is this correct?

Magnus

LGTM

Magnus,

You could set SoapUi to use a proxy server and point it to the Gatling recorder. Then send the webservice call from SoapUi while the Gatling recorder is in recording mode. In the generated script the webservice payload will be in a request-body, referenced as a .body(rawFileBody(). If you change this to ELFileBody you can use EL to dynamically modify the request body.

Cheers

Daniel

Yep, if you’re not familiar with SOAP and the how the service you’re testing works (like expected headers), Daniel’s method is the way to go.

Daniel,
Thank you for the tip.

I have done as you said, pointed soapUI to localhost:8000, that is the config in the recorder. I started the recorder and ran the request from soapUI.
I got this generated script in the simulations folder of Gatling:

package tezting

import io.gatling.core.Predef._
import io.gatling.http.Predef._

class soapUiAsProxy extends Simulation {
val httpProtocol = http
.baseURL(“http://www.webservicex.net:-1”)
.inferHtmlResources()
.acceptEncodingHeader(""“gzip,deflate”"")
.contentTypeHeader(""“text/xml;charset=UTF-8"”")
.userAgentHeader(""“Apache-HttpClient/4.1.1 (java 1.5)”"")
val headers_0 = Map(""“SOAPAction”"" → “”"“http://www.webserviceX.NET/ChangeMetricWeightUnit”""")
val uri1 = “”“www.webservicex.net”""
val scn = scenario(“soapUiAsProxy”)
.exec(http(“request_0”)
.post("""/convertMetricWeight.asmx""")
.headers(headers_0)
.body(RawFileBody(“soapUiAsProxy_request_0000.txt”)))
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}

Now I wonder how do I “If you change this to ELFileBody you can use EL to dynamically modify the request body.”

Is this .txt file stored somewhere and how do I use EL to dynamically modify the request body?

Thanks a lot for gret help so far, this is just what I need.

Magnus

Found the RawFileBody (.txt file) in the folder C:\Gatling 2.0\gatling-charts-highcharts-2.0.0-RC4\user-files\request-bodies.
But running the simulation as is results in error:
---- Errors --------------------------------------------------------------------

file soapUiAsProxy_request_0000.txt doesn’t exist 1 (100,0%)

As ecspected maybe, but then I need to “change this to ELFileBody you can use EL to dynamically modify the request body”
That is what I am wondering about right now…

Magnus

Magnus,

Your Gatling installation path seems to contain white spaces, that is probably the reason you get the file not found error, please check http://gatling.io/docs/2.0.0-RC4/quickstart.html

As for your question about ELFileBody: it depends on your use case if you need it. If you want to make some value in your request variable, for instance form a list of values, you can use ELFileBody. Can you please explain what you are trying to accomlish?

Cheers

Daniel

Hi Daniel,
I want to use gatling to test soap webservices.
It is not (at the moment) very important to vary values in the requests, just get it to work.
I have edited the path so it does not contain white-Spaces, but still I get the file dont exists.

I have copied the file into my IntelliJ IDEA and is also exists int the folder C:\Gatling-2.0\gatling-charts-highcharts-2.0.0-RC4\user-files\request-bodies

I hope it is possible to say:

.body(RawFileBody(“OilSimulation_request_0000.txt”)))

when the file exists in the folder …\user-files\request-bodies

Or?

BTW: The SoapUI Project it Attached. Maybe you could try to record the request and see if it works for you?

Thanks!

Magnus

soapUIProjectToUseWithGatling.zip (2.03 KB)

Except for this bug I just fixed, recording from Recorder + SoapUi and replaying worked perfectly fine for me.
I tested on OSX, not on Windows though (don’t have one here).

Do the attached files work for you?

Soap_request_0000.txt (458 Bytes)

Soap.scala (658 Bytes)

Hi, I might have placed the file “Soap_request_0000.txt” in the wrong dir, but it is located in C:\Gatling-2.0\gatling-charts-highcharts-2.0.0-RC4\user-files\request-bodies. I do not know where Gatling lokks for files when you say:

.body(RawFileBody(“Soap_request_0000.txt”)))

I have also placed it in the file structure of my IntelliJ Project like the attachment describes.

Still not working, same erro msg. It cannot find the file.

Magnus

Where should I put the “Soap_request_0000.txt” file?

Magnus

Magnus,

In the IDEPathHelper.scala file you can find where gatling looks for the request-bodies.

Cheers

Daniel

Daniel,
I had placed the .txt file with the soap body inside folder “data” within the folder “Resources”.
I moved it one foler out to “resorces” and it worked!

My bad…
I have to place all files containg the request bodies directly in the resources folder to make this work.

Magnus

Lets now say I want to vary the input data in the request body file looking like this:

<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:web=“http://www.webserviceX.NET/”>
soapenv:Header/
soapenv:Body
web:ChangeMetricWeightUnit
web:MetricWeightValue30</web:MetricWeightValue>
web:fromMetricWeightUnitkilogram</web:fromMetricWeightUnit>
web:toMetricWeightUnitgram</web:toMetricWeightUnit>
</web:ChangeMetricWeightUnit>
</soapenv:Body>
</soapenv:Envelope>

This is why one would use ELFile right?
Could you please show me how I “parameterize” the request body file within the scala simulation script? Lets say I want to use different values for “MetricWeightValue” with each user ie.

Cheers,

Magnus

Replace the value in the request body with a session variable placeholder, e.g. ${weight}.

Then, for instance, use a feeder (http://gatling.io/docs/2.0.0-RC4/session/feeder.html) to feed your session values for the "weight" variable.

Ok,
so my request body would then look like this:

<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:web=“http://www.webserviceX.NET/”>
soapenv:Header/
soapenv:Body
web:ChangeMetricWeightUnit
web:MetricWeightValue${weight}</web:MetricWeightValue>
web:fromMetricWeightUnitkilogram</web:fromMetricWeightUnit>
web:toMetricWeightUnitgram</web:toMetricWeightUnit>
</web:ChangeMetricWeightUnit>
</soapenv:Body>
</soapenv:Envelope>

and my simulation would look like below but how do I implement that it should use weight from i.e. a .csv file each time?

package tezting

import io.gatling.core.Predef._
import io.gatling.http.Predef._

class soapUiAsProxy extends Simulation {
val httpProtocol = http
.baseURL(“http://www.webservicex.net:-1”)
.inferHtmlResources()
.acceptEncodingHeader(""“gzip,deflate”"")
.contentTypeHeader(""“text/xml;charset=UTF-8"”")
.userAgentHeader(""“Apache-HttpClient/4.1.1 (java 1.5)”"")
val headers_0 = Map(""“SOAPAction”"" → “”"“http://www.webserviceX.NET/ChangeMetricWeightUnit”""")
val uri1 = “”“www.webservicex.net”""
val scn = scenario(“soapUiAsProxy”)
.feed(csv(“weights.csv”).random)
.exec(http(“request_0”)
.post("""/convertMetricWeight.asmx""")
.headers(headers_0)
.body(RawFileBody(“soapUiAsProxy_request_0000.txt”))) //But how do I state that it should use ${weight} for each request?
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}

Change

.body(RawFileBody("soapUiAsProxy_request_0000.txt")))

To

.body(ELFileBody("soapUiAsProxy_request_0000.txt")))