Getting 400 response in Gatling After Mapping whereas same service works correctly in SOAP UI

Hi Team,

I am trying to map a working soap request to Gatling seems very basic but i keep getting 400 error in Gatling whereas i am getting 200 OK in SOAP UI

Here is SOAP UI details :-

Raw–>
POST http://r21sVCS.onlinegaming.local:4059/Business/EventReporterV2 HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: “http://www.ds.com/Service/2013-03/IEventReporterEndpoint/GetAccountVersion
Content-Length: 385
Host: r20services.onlinegaming.local:4059
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

XML–>
<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:ns=“http://www.ds.com/Service/2013-03”>
soapenv:Header/
soapenv:Body
ns:GetAccountVersion

ns:request
ns:UserName?</ns:UserName>
</ns:request>
</ns:GetAccountVersion>
</soapenv:Body>
</soapenv:Envelope>

Now the equivalent Gatling code is :-

package simulations

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

import scala.language.postfixOps

class ERBSGetServiceVersion extends BaseSimulation {

val httpProtocol = http
.baseURL(“http://r21sVCS.onlinegaming.local:4059/Business/EventReporterV2”)

val header = Map(
“POST” → “http://r21sVCS.onlinegaming.local:4059/Business/EventReporterV2 HTTP/1.1”,
“Accept-Encoding” → “gzip,deflate”,
“Content-Type” → “text/xml;charset=UTF-8”,
“SOAPAction” → “http://www.ds.com/Service/2013-03/IEventReporterEndpoint/GetAccountVersion”,
“Content-Length” → “385”,
“Host” → “r21sVCS.onlinegaming.local:4059”,
“Connection” → “Keep-Alive”,
“User-Agent” → “Apache-HttpClient/4.1.1 (java 1.5)”
)

val scn = scenario(“SOAPRecordedSimulation”)
.exec(http(“Get Service Soap Request”)
.post(" HTTP/1.1")
.headers(header)
.body(StringBody("""<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:ns=“http://www.ds.com/Service/2013-03”>

soapenv:Header/
soapenv:Body
ns:GetAccountVersion

ns:request
ns:UserName?</ns:UserName>
</ns:request>
</ns:GetAccountVersion>
</soapenv:Body>
</soapenv:Envelope>""")))
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)

}

Kindly Note this service doesnt requires authentication but still Gatling throws 400

17:11:56.245 [WARN ] i.g.h.a.ResponseProcessor - Request ‘Get Service Soap Request’ failed: status.find.in(200,304,201,202,203,204,205,206,207,208,209), but actually found 400

I think you’ll need to .stripMargin on your request’s StringBody - I don’t think your xml parser will like the pipes