I'm testing a SOAP service that accepts a request with an optional field. Below is a request body snippet to illustrate.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<findPerson>
<request>
<!-- Optional field: -->
<firstName>${FIRST_NAME}</firstname>
</request>
</findPerson>
</soapenv:Body>
</soapenv:Envelope>
And the following is an extract from my current scenario setup in Scala:
scenario("Send FindPerson-request")
[...]
.feed(firstNameFeeder)
.exec(
http("FindPerson")
.post(serviceUrl)
.body(ELFileBody("bodies/FindPersonRequestBody.ssp"))
[...]
)
What I'm trying to do is to not include the <firstName>
element in the request at all whenever the firstNameFeeder
returns a null
.
So far I've solved the problem by writing a bunch of custom Scala code to inject actual HTML tags into the request body depending on whether or not the feeder yields any data, but this is starting to become very cumbersome, and I feel like I'm in many ways working against the Gatling framework.
Am I missing something? Is there a better way to do this? I checked the documentation and noticed support for templating frameworks such as Mustache has been removed, but from my point of view, that could've been really useful in this case.