| 11 July 2007 |
Well, I think it is clear now I am a big fan of SoapUI. So here is another post about it. This time I explain how you can use it to perform a load test for your webservice and how to work around a common issue with this test. One of the business rules we have is that a message may only be processed succesfully once. To implement this, a unique referenceNumber is supplied in the body of the SOAP message (I know, it was better to use a policy for that by adding a SOAP header, but this is a piece of legacy I have to deal with). In the webservice (actually in a XFire handler) the referenceNumber is checked against all processed referenceNumbers in a database and if it already exists, a fault message is returned.
To avoid this fault message in our load test we added several steps to our Soap UI testcase that increases this referenceNumber, so it's unique for every message.
Here is an example of how to do this. First I created a webservice that just echoes the inputted string. Here is the WSDL:
-
<wsdl:definitions targetNamespace="http://net.pascalalma.services/EchoService">
-
<wsdl:types>
-
<xsd:schema targetNamespace="http://net.pascalalma.services/EchoService" elementFormDefault="qualified" attributeFormDefault="qualified">
-
<xsd:element name="s" type="xsd:string"/>
-
<xsd:element name="echoAnswer" type="xsd:string"/>
-
</xsd:schema>
-
</wsdl:types>
-
<wsdl:message name="echoRequest">
-
<wsdl:part element="tns:s" name="s"/>
-
</wsdl:message>
-
<wsdl:message name="echoResponse">
-
<wsdl:part element="tns:echoAnswer" name="echoAnswer"/>
-
</wsdl:message>
-
<wsdl:portType name="EchoService">
-
<wsdl:operation name="echo">
-
<wsdl:input message="tns:echoRequest" name="echoRequest"/>
-
<wsdl:output message="tns:echoResponse" name="echoResponse"/>
-
</wsdl:operation>
-
</wsdl:portType>
-
<wsdl:binding name="EchoServiceHttpBinding" type="tns:EchoService">
-
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
-
<wsdl:operation name="echo">
-
<wsdlsoap:operation soapAction="urn:echo"/>
-
<wsdl:input name="echoRequest">
-
<wsdlsoap:body use="literal"/>
-
</wsdl:input>
-
<wsdl:output name="echoResponse">
-
<wsdlsoap:body use="literal"/>
-
</wsdl:output>
-
</wsdl:operation>
-
</wsdl:binding>
-
<wsdl:service name="EchoService">
-
<wsdl:port binding="tns:EchoServiceHttpBinding" name="EchoServiceHttpPort">
-
<wsdlsoap:address location="http://localhost:8080/XFireTest/services/EchoService"/>
-
</wsdl:port>
-
</wsdl:service>
-
</wsdl:definitions>
I then created a TestCase based on this WSDL and added four steps:
- A properties step
In this step a property is defined to be used in this TestCase.
- A Groovy Script step
This step has the logic to increase the property that is defined in the step before.
- A Transfer step
With this step we copy the value of the (modified) property into the SOAP request before we send it to our webservice.
- The SOAP request step
Final step is sending the request with the modified value.
Now when all this is in place you can run a simple loadtest like this:
In the server where my webservice is running you will get out put like this:
As you can see each call gets a unique number.
Now we change the LoadTest to have multiple threads accessing the webservice at the same time. When we do that like this:
the output becomes:
Now the generated numbers are no longer unique!
To fix this I have added a property and changed the Groovy Script Step so it adds the thread index to the unique part. The Property Step and the Groovy Step become like:
and
And the output now is:
Now that looks better, doesn't it? All generated ID's are unique again for every message.


15 comments to 'Another common issue solved with Soap UI'
17 July 2007
This is great! Exactly the sort of thing I need to do. Googled it and found you. Thanks!
KAC
20 July 2007
Good to see you like the tool Pascal! You have some nice posts here btw..
14 August 2007
Great Work Pascal, your text is very informative. Thanks for the info, i'm just about to start using this tool. Keep up the great work!
21 February 2008
You might want to try and use the properties you define directly in the request using jstl-like syntax like this: ${uniqueTxt}
Using properties like this makes it possible to skip the property transfer step.
22 February 2008
Hi Gabriel,
You're right about the EL syntax. In real life I would use this notation in this simple case. The Property Transfer step should be used in more complex cases.
8 July 2008
Hi, anyone help me to read data from excel sheet and dynamically appy that value into SoapUI request
Thanks,
Natarajan
8 July 2008
@natarajan
That would be a nice feature. I haven't seen it anything like it until now, but maybe someone else has done it before??
30 July 2008
Is there a way to change a testsuite property rather than teststeps property?
1 August 2008
@Ricard
Yes, I believe in a Groovy step you can refer to 'context.setProperty( “myValues”, "blabla")' but you might check the documentation for the details. But is must be possible.
7 August 2008
Thanks for your response Pascal. I tried this. unfortunately I couldn't get it to work. Perhaps I'm doing something wrong...
19 August 2008
hii pascal is this Soap UI a Record and Play back testing tool?????
20 August 2008
Hi Raman,
I am not sure what you would like to record, but you can use the Response from one Soap call as input parameter for a next call.
Hope this helps.
7 November 2009
Thanks for the great tutorial. I will point my soapUI users to it.
Please take a look at PushToTest TestMaker to take soapUI to the next level. TestMaker enables soapUI tests to run at large load test levels, run in a cloud environment, provides hundreds of root cause analysis reports, and correlates soapUI activity to monitored resources. A tutorial on soapUI integration in TestMaker is at http://tinyurl.com/yzar9yz.
-Frank Cohen
PushToTest
13 April 2010
is there a option to record and play back it in soapUI
29 April 2010
I need to send the input parameter as text file like mobile no's.