SOAP UI is an excellent tool to test the web services.
Though there are many tools available in the market to test the web service, I
would prefer SOAP UI for its flexibility, ease of use and vast number of
features. We have been using the SOAP UI to test various secure services, test
the connectivity between SOA servers, Load testing and performance testing etc.
I am not a full time tester and not an expert in SOAP UI tool, but this is an
attempt to unleash the SOAP UI as a developer. To be honest, many features are
learnt through trial and error. In this article, the following points are
- Downloading SOAP UI
- First SOAP UI project
- Adding Assertions
While developing B2B application, web services plays a vital part since most of the services are exposed as web service. This enables a wide range of clients access the web service. It is really important that the web services adhere to the standard non-funtional requirements like minimum response time, no fault etc. as well as any rules imposed by the client. SOAP UI plays a major role in testing the fitness of a web service.
First SOAP UI project
Right, let us start with the first SOAP UI project. This
SOAP UI project will test a simple interest calculator which is exposed as web
service. I have chosen this, because, I don’t want to spend too much time
explaining the business logic of the web service and that is also not the scope
of this article. So, our simple interest calculator will "simply" calculate the
simple interest using the formula,
Simple Interest SI = (Principal amount (P) x Number of years
(N) x rate of interest (R)) / 100,
For example, If P = 10000, N = 2 yrs and R = 20% (which no banks will give nowadays), the simple
interest would be,
SO = (P*N*R)/100 = 4000
In web service terms, the service will accept three parameters principal, number of years and rate of interest and return the interest as output. The sample code is given below;
public class SimpleInterest : System.Web.Services.WebService
public double SimpleInterestcal(int principalAmount, float rateofInterest, int loanPeriod)
double interest = 0;
return interest = (principalAmount * rateofInterest * loanPeriod) / 100;
The sample request / response is given below.
Ok, so the web service is working fine. Now, lets go to the
SOAP UI Part.
The end point of this service is;
Picture 1: Create a new SOAP UI Project. Using file menu, create a new SOAP UI Project.
Picture 2: Project is loaded in left pan. Double click request 1 will load the request / response tab
Picture 3: sample request / response
Edit the request tab and fill the values. Press the green
button to get the response.
So, the SOAP UI project to test the simple interest
calculator is working. One can edit the service to test with various values. If
there is a schema violation, the SOAP UI client will throw error. For example,
if the principal value which by definition is an integer field will throw error
if a double or alphabet is sent.
For example, if the principal amount field was sent as
100ABCD, the response would be a SOAP fault thrown by client. Similarly for any
violation in schema if the input field was enum will be handled by SOAP client
and error will be thrown back. It is a good practice to define the most precise
datatypes for the fields since it will avoid unnecessary validations at the
Similarly, if there is a fault handler available at the
service end, then the SOA fault sent by service will be caught and sent back.
Again it is a very good practice to send back valid readable error message like
"invalid principal amount" etc., rather than sending the stack trace.
Assertions are more important because, the SOAP UI is used
for testing the web service performance and therefore the fitness of a service
can be established only by having some metrics to measure the performance.
Assertions can be added to the load test as well as against
the request. The load test assertions are:
- Max error
- Step Average
- Step TPS
- Step Maximum
- Step Status
The assertions that can be added on the test step are:
- Invalid HTTP status code
- JMS timeout
- WS –Security status
- Not SOA fault
- Response SLA
- Valid HTTP status code
- SOAP response
- Script assertion
- WS –addressing response
- Xpath match
- Xquery match
- Sensitive information exposure
- JMS status
- Schema compliance
- SOAP fault
- Not contains
A load testing of a web service must have as many assertions
as required which tests various parameters of the service. In the follow up
article, I will run a load test, which will have the following assertions.
- Maximum error allowed in 3
- Response SLA is 2 seconds
- Contains the response code as "0" which indicates the successful execution
- Not a SOAP fault and much more.
Points of interest
in this article we went through a brief introduction of SOAP UI tool. More on the load testing will be added in the follow up article.
- 1. 0.1 Initial version -21st June 2012