parameter in soap request

I want to use parameter in my soap request.
This is my request:

<SOAP:Envelope xmlns:SOAP=“http://schemas.xmlsoap.org/soap/envelope/”>
SOAP:Body





top
busauthenticationuser


${user}


${user}


${user}





</SOAP:Body>
</SOAP:Envelope>

Before posting this request to the gateway, i want to change it. I tried it with following code:

.exec(http(“request_2”)
.post("/home/system/com.eibus.web.soap.Gateway.wcp")
.headers(headers_1)
.basicAuth(“gschippe”, “Cordys123”)
.param(“user”, “GJ”)
.fileBody(“userb.txt”).asXML

But that’s not working. Any idea how to use parameters in my soap body?

Hi,

If you want to make your body dynamic, you have to make it a proper scalate
SSP template and pass it the required parameters, like explained here:
https://github.com/excilys/gatling/wiki/HTTP#wiki-template-body

Cheers,

Stéphane

Thanks! That is working. But I’m now using another request and that one is not working. How to print the request that is being sent to the gateway.
This is my logback.xml:

But I don’t see the request.

Logging the request body is a 1.4.0 feature:
https://github.com/excilys/gatling/issues/848

You'll have to either wait for 1.4.0 (hopefully next week), or use the
latest SNAPSHOT (
https://github.com/excilys/gatling/wiki/Continuous-Integration).
Beware that you'll have to migrate your Simulation: basically, you no
longer need to put things in an apply method, but you have to use setUp()
in order to register your scenarios. You also have to remove ".configure"
when configuring a scenario.

You can also use a tool such as Charles proxy so see what happens on the
wire.

Stéphane

Hi,

I also want to have dynamic bodies but I am not using fileBody instead I am using .body()… how can I achieve this

this is my scenario

def SAMLAuthenticationSoapRequest = “”"<SOAP:Envelope xmlns:SOAP=“http://schemas.xmlsoap.org/soap/envelope/”>
SOAP:Header
<wsse:Security xmlns:wsse=“http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd”>
<wsse:UsernameToken xmlns:wsse=“http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd”>
wsse:Username${username}</wsse:Username>
wsse:Password${password}</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP:Header>
SOAP:Body
<samlp:Request xmlns:samlp=“urn:oasis:names:tc:SAML:1.0:protocol”
MajorVersion=“1” MinorVersion=“1”
IssueInstant=“2009-04-01T10:23:11Z”
RequestID=“a997c83a8d-b5d7-b930-edba-02e37ab1765”>
samlp:AuthenticationQuery
<saml:Subject xmlns:saml=“urn:oasis:names:tc:SAML:1.0:assertion”>
<saml:NameIdentifier Format=“urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified”>${username}</saml:NameIdentifier>
</saml:Subject>
</samlp:AuthenticationQuery>
</samlp:Request>
</SOAP:Body>
</SOAP:Envelope>"""

val scn = scenario(“SAML Authentication Scenario”)
//.feed(userCredentials)
.exec(http(“Login Request”)
.post("/cordys/com.eibus.web.soap.Gateway.wcp")
.headers(headers_1)
.body(SAMLAuthenticationSoapRequest)
.param(“username”, “cordys”)
.param(“password”, “cordys123”))

Regards
Amuthan

Hi,

First, use a val, not a def as it’s static.

What’s the problem with what you’ve written? It looks fine to me.

Cheers,

Stéphane

Hi,

If you noticed closely, I have assigned a soap request to the variable called "SAMLAuthenticationSoapRequest ", the soap request I assigned got some place holders namely ${username} and ${password},

wsse:Username${username}</wsse:Username>
wsse:Password${password}</wsse:Password>

I could able to fill this place holders if I use .fileBody() construct with request body located in a seperated template file, but If I want to use .body() construct, how can I fill this place holders that is my basic question… I have tried .param() but it is just a post parameter it is not get replaced in soap request

Regards
Amuthan

OK,

You’re misunderstanding the meaning of the param method.
See https://github.com/excilys/gatling/wiki/HTTP#wiki-post-parameters

param is for passing form parameters, not for passing values to a template.

Gatling EL pulls data out of the user’s session.
You have 3 ways of setting data into the user’s session:

Cheers,

Stéphane

okay I understand, but to use session I have to use scenario, but all I want to have is just a replaceable http actions which I can mix and match with different combination at the end, in many scenarios, in that case I would like to have a http action with body which can have some place holders in it to make it generic enough…

So my question here is why can’t we allow to pass a parameter map to .body() construct which is similar to filebody() ?

kind regards
Amuthan

Because if what you’re trying to achieve is static, ie non user specific, you don’t need an expression that will be resolved against dynamic user Session data.

Is this what you’re trying to do?

def SAMLAuthenticationSoapRequest(username: String, password: String) = “”"<SOAP:Envelope xmlns:SOAP=“http://schemas.xmlsoap.org/soap/envelope/”>
SOAP:Header
<wsse:Security xmlns:wsse=“http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd”>
<wsse:UsernameToken xmlns:wsse=“http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd”>
wsse:Username""" + username + “”"</wsse:Username>
wsse:Password""" + password + “”"</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP:Header>
SOAP:Body
<samlp:Request xmlns:samlp=“urn:oasis:names:tc:SAML:1.0:protocol”
MajorVersion=“1” MinorVersion=“1”
IssueInstant=“2009-04-01T10:23:11Z”
RequestID=“a997c83a8d-b5d7-b930-edba-02e37ab1765”>
samlp:AuthenticationQuery
<saml:Subject xmlns:saml=“urn:oasis:names:tc:SAML:1.0:assertion”>
<saml:NameIdentifier Format=“urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified”>${username}</saml:NameIdentifier>
</saml:Subject>
</samlp:AuthenticationQuery>
</samlp:Request>
</SOAP:Body>
</SOAP:Envelope>"""

val scn = scenario(“SAML Authentication Scenario”)
//.feed(userCredentials)
.exec(http(“Login Request”)
.post("/cordys/com.eibus.web.soap.Gateway.wcp")
.headers(headers_1)
.body(SAMLAuthenticationSoapRequest(“cordys”, “cordys123”)))

yes… that is what I am trying… and it is working nicely… let me give you brief Idea of what I am trying to achieve… I am having some couple of soap requests, the user can perform some action by selecting some of these soap request combine them in an particular sequence of order. but soap request are more specific but with some replaceable part in it which we can make it as generic template…

for example

<SOAP:Envelope xmlns:SOAP=“http://schemas.xmlsoap.org/soap/envelope/”>
SOAP:Body
<Get${entityName} xmlns=“http://schemas.cordys.com/entities/lt/{entityName}” preserveSpace=“no” qAccess=“0” qValues="">
<{entityName}Id>1</{entityName}Id>
</Get{entityName}>
</SOAP:Body>
</SOAP:Envelope>"""

So I have put each request in a separate scala object (in a file called GetEntitySOAP.scala) something like as follows

def getEntityRequstBody = “”<SOAP:Envelope xmlns:SOAP=“http://schemas.xmlsoap.org/soap/envelope/”>
SOAP:Body
<Get${entityName} xmlns=“http://schemas.cordys.com/entities/lt/{entityName}” preserveSpace=“no” qAccess=“0” qValues="">
<{entityName}Id>1</{entityName}Id>
</Get{entityName}>
</SOAP:Body>
</SOAP:Envelope>"""

def getEntity() = http(“getEntity Request”)
.post("/home/system/com.eibus.web.soap.Gateway.wcp")
.body(SAMLAuthenticationSoapRequest))

and trying to use that in a seperate simulation file as follows

val readEntityInstanceScn = scenario(“Read Entities Scenario”)
.exec(GetEntitySOAP.getEntity())

is this approach is good enough or can we have better approach to accomplish this in more modular fashion

Kind Regards
Amuthan

Looks good to me.

Hi,Stéphane
Hope you will be doing fine.
I have a soap request
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import bootstrap._

object ConsultProductsScenario {
val products = csv(“sql_time_demo.csv”).random
feed(products)
def SAMLAuthenticationSoapRequest = “”"<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:rep=“http://www.nextone.com/ivms/schema/reportservice”>
soapenv:Header/
soapenv:Body
rep:get
<com:credential xmlns:com=“http://www.nextone.com/ivms/schema/common”>
com:userroot</com:user>
com:passwordshipped!!</com:password>
com:partitionadmin</com:partition>
</com:credential>


GMT

1
“${sbc}”
Engineering
NER by Destination Reg ID
true

</rep:get>
</soapenv:Body>
</soapenv:Envelope>"""

val scn = scenario(“SAML Authentication Scenario”)
//.feed(userCredentials)
.exec(http(“Get data”)
.post(“https://10.216.220.10:443/rsm/ws/prov/reportservice”)
.body(SAMLAuthenticationSoapRequest)
.check(status.is(200)))
}

csv file content is :
starttime,endtime,sbc
2014-09-16T09:10:00.000+00:00,2014-09-16T09:20:00.000+00:00,msx89
2014-09-16T09:20:00.000+00:00,2014-09-16T09:30:00.000+00:00,msx90
2014-09-16T09:30:00.000+00:00,2014-09-16T09:40:00.000+00:00,msx91
2014-09-16T09:40:00.000+00:00,2014-09-16T09:50:00.000+00:00,msx92

when i run the simulator it exit with error message
5:40:49.706 [ERROR] i.g.h.a.HttpRequestAction - No attribute named ‘productIdFound’ is defined
15:40:49.714 [ERROR] i.g.h.a.HttpRequestAction - No attribute named ‘productIdFound’ is defined
15:40:49.715 [ERROR] i.g.h.a.HttpRequestAction - No attribute named ‘productIdFound’ is defined
Exception in thread “main” java.lang.UnsupportedOperationException: There were no requests sent during the simulation, reports won’t be generated
at io.gatling.charts.report.ReportsGenerator$.generateFor(ReportsGenerator.scala:41)
at io.gatling.app.Gatling.generateReports$1(Gatling.scala:156)
at io.gatling.app.Gatling.start(Gatling.scala:209)
at io.gatling.app.Gatling$.fromMap(Gatling.scala:58)
at io.gatling.app.Gatling$.runGatling(Gatling.scala:79)
at io.gatling.app.Gatling$.main(Gatling.scala:53)
at io.gatling.app.Gatling.main(Gatling.scala)

can you please let me know what is the problem in my code.

Thanks and regards,
Piyush Pathak

You commented the feed line, so attributes are not populated and Gatling can’t resolve your expressions such as ${starttime}, so it can’t send the requests.