parameter in soap request

1,903 views
Skip to first unread message

Gert Jan Schipper

unread,
Dec 12, 2012, 4:38:56 AM12/12/12
to gat...@googlegroups.com
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>
<Update xmlns="http://schemas.cordys.com/1.0/ldap" xmlns:clientattr="http://schemas.cordys.com/General/ClientAttributes/" clientattr:sync_id="0">
<tuple clientattr:sync_id="7">
<new>
<entry xmlns="http://schemas.cordys.com/1.0/ldap" dn="cn=${user},cn=authenticated users,cn=cordys,cn=build1353,o=vanenburg.com">
<objectclass>
<string>top</string>
<string>busauthenticationuser</string>
</objectclass>
<cn>
<string>${user}</string>
</cn>
<description>
<string>${user}</string>
</description>
<osidentity>
<string>${user}</string>
</osidentity>
</entry>
</new>
</tuple>
</Update>
</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?

Stéphane Landelle

unread,
Dec 12, 2012, 4:49:18 AM12/12/12
to gat...@googlegroups.com
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:

Stéphane

2012/12/12 Gert Jan Schipper <gjschi...@gmail.com>
asXML

Gert Jan Schipper

unread,
Dec 12, 2012, 5:20:04 AM12/12/12
to gat...@googlegroups.com
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:

<logger name="com.excilys.ebi.gatling.http.ahc.GatlingAsyncHandler" level="DEBUG" /> 
<root level="DEBUG">
<appender-ref ref="CONSOLE" />
</root>

But I don't see the request.

Op woensdag 12 december 2012 10:49:18 UTC+1 schreef Stéphane Landelle het volgende:

Stéphane Landelle

unread,
Dec 12, 2012, 5:28:44 AM12/12/12
to gat...@googlegroups.com
Logging the request body is a 1.4.0 feature:

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




2012/12/12 Gert Jan Schipper <gjschi...@gmail.com>
request

Amuthan G

unread,
Mar 11, 2013, 9:04:15 AM3/11/13
to gat...@googlegroups.com
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

Stéphane Landelle

unread,
Mar 11, 2013, 10:01:48 AM3/11/13
to gat...@googlegroups.com
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


2013/3/11 Amuthan G <amu...@cordys.com>

--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Amuthan G

unread,
Mar 12, 2013, 2:33:44 AM3/12/13
to gat...@googlegroups.com
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

--
You received this message because you are subscribed to a topic in the Google Groups "Gatling User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gatling/SNdjPKZDMDs/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to gatling+u...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--

Kind Regards
Amuthan G
Software Engineer
amu...@cordys.com
www.cordys.com
T 040-66561982 • M +91 7799697766

Cordys - The Enterprise Cloud Platform

Stéphane Landelle

unread,
Mar 12, 2013, 4:20:06 AM3/12/13
to gat...@googlegroups.com
OK,

You're misunderstanding the meaning of the param method.

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:
In your case, remove the .param lines and uncomment your feeder.

Cheers,

Stéphane


2013/3/12 Amuthan G <amu...@cordys.com>

Amuthan G

unread,
Mar 12, 2013, 6:48:05 AM3/12/13
to gat...@googlegroups.com
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

Stéphane Landelle

unread,
Mar 12, 2013, 6:54:10 AM3/12/13
to gat...@googlegroups.com
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")))


2013/3/12 Amuthan G <amu...@cordys.com>

Amuthan G

unread,
Mar 12, 2013, 7:28:24 AM3/12/13
to gat...@googlegroups.com
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
    

Stéphane Landelle

unread,
Mar 12, 2013, 9:30:33 AM3/12/13
to gat...@googlegroups.com
Looks good to me.


2013/3/12 Amuthan G <amu...@cordys.com>

piyush...@globallogic.com

unread,
Sep 18, 2014, 6:19:51 AM9/18/14
to gat...@googlegroups.com
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:user>root</com:user>
            <com:password>shipped!!</com:password>
            <com:partition>admin</com:partition>
         </com:credential>
         <filter type="subtree" beginDate="${starttime}" endDate="${endtime}" pageIndex="1" pageSize="100">
            <report>
               <timeZone>GMT</timeZone>
            </report>
            <partition>1</partition>
            <deviceName>"${sbc}"</deviceName>
            <reportDomain>Engineering</reportDomain>
            <reportSubType>NER by Destination Reg ID</reportSubType>
            <total>true</total>
         </filter>
      </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

Stéphane Landelle

unread,
Sep 18, 2014, 6:33:10 AM9/18/14
to gat...@googlegroups.com
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.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages