Wednesday, 14 November 2012

How to dynamically increment values using groovy script in SOAPUI

How to dynamically increment values using groovy script in SOAPUI

Lets say we want to load test our webservices and we want to have dynamic values for some of the fields in the request xml.

Thanks to my collegue Peter Blackburn we found out that we can create a groovy script which can help us in this case.

Steps to be followed

1) In the Test Steps, make the first step a Groovy Script. Mine looks like this:

if (context.LoadTestContext.requestId == null) { context.LoadTestContext.requestId = new java.util.concurrent.atomic.AtomicLong(100); } if (context.LoadTestContext.phoneNumber == null) { context.LoadTestContext.phoneNumber = new java.util.concurrent.atomic.AtomicLong(1000000101); } context.requestIdCurrent = context.LoadTestContext.requestId.getAndIncrement(); context.phoneNumberCurrent = context.LoadTestContext.phoneNumber.getAndIncrement(); 2) In your XML request, refer to the values you have just defined as follows: <xml> ... <soapenv:Body> <ns:TempRequest> <ns:requestHeader> <ns1:id>${requestIdCurrent}</ns1:id> </ns:requestHeader> <ns:telephoneNumber>${phoneNumberCurrent}</ns:telephoneNumber> </ns:TempRequest> </soapenv:Body> </soapenv:Envelope> </xml>

2 comments:

Anonymous said...

ルイヴィトン 財布は、最も 大事 宝物 残り によって 歴史 オージー
男性。 これらの種類の ルイヴィトン として 共通 ミニ
ルイヴィトン の日暮れなどなど。異なる 部品 されている 作成 に 例外的な シープスキン 財布。 A 高品質 シープスキンです 厳しい と
かなり 密 ながら 維持 柔らかさ。

my blog グッチ

Anonymous said...

The resort assortment is at present on shop cabinets at Saks Fifth Avenue.
Hysteria line is designed into six different glamorous designs.
Its triangular variety makes it comfy under the arm. Readers to the shop will find out about the manner house's loaded heritage and heritage. http://www.mercatousato.com/eng/userinfo.php?uid=15270