Click here to Skip to main content
15,884,628 members
Articles / DevOps / Load Testing

SOAP UI - Part 1 - Introduction

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
22 Jun 2012CPOL4 min read 55.3K   16   6
This is a article on SOAP UI. This is used for web service load testing

Introduction

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 covered:

  1. Downloading SOAP UI
  2. First SOAP UI project
  3. Adding Assertions

Background

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;

C#
 public class SimpleInterest : System.Web.Services.WebService
{
    //Default constructor
    public SimpleInterest()
    {
    }


    /// <summary>
    /// This method will calculate the simple interest
    /// </summary>
    /// <param name="principalAmount">Principal amount</param>
    /// <param name="rateofInterest">Rate</param>
    /// <param name="loanPeriod">Number of years</param>
    /// <returns>Simple interest</returns>
    [WebMethod]
    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.

Request

XML
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <SimpleInterestcal xmlns="http://tempuri.org/">
      <principalAmount>10000</principalAmount>
      <rateofInterest>20</rateofInterest>
      <loanPeriod>2</loanPeriod>
    </SimpleInterestcal>
  </soap12:Body>
</soap12:Envelope>

Response

XML
<?xml
version="1.0" encoding="utf-8"?>
<soap12:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <SimpleInterestcalResponse
xmlns="http://tempuri.org/">
      <SimpleInterestcalResult>4000</SimpleInterestcalResult>
    </SimpleInterestcalResponse>
   </soap12:Body>
</soap12:Envelope>

Ok, so the web service is working fine. Now, lets go to the SOAP UI Part.

The end point of this service is;

http://localhost:54350/SimpleInterest/SimpleInterest.asmx?wsdl

Picture 1: Create a new SOAP UI Project. Using file menu, create a new SOAP UI Project.

Image 1

Picture 2: Project is loaded in left pan. Double click request 1 will load the request / response tab

 Image 2

Picture 3: sample request / response

Edit the request tab and fill the values. Press the green button to get the response.

Image 3

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 server end.

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

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:

  1. Max error
  2. Step Average
  3. Step TPS
  4. Step Maximum
  5. Step Status

The assertions that can be added on the test step are:

  1. Invalid HTTP status code
  2. JMS timeout
  3. WS –Security status
  4. Not SOA fault
  5. Response SLA
  6. Valid HTTP status code
  7. SOAP response
  8. Script assertion
  9. WS –addressing response
  10. Contains
  11. Xpath match
  12. Xquery match
  13. Sensitive information exposure
  14. JMS status
  15. Schema compliance
  16. SOAP fault
  17. 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.

  1. Maximum error allowed in 3
  2. Response SLA is 2 seconds
  3. Contains the response code as "0" which indicates the successful execution
  4. 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.

History

  • 1. 0.1 Initial version  -21st June 2012

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) TATA Communications
India India
I have a total experience of around 5 years out of which 4 years in MS technologies. I have a passion towards coding.

Comments and Discussions

 
QuestionError Loading WSDL Pin
Member 1090839026-Jun-14 7:45
Member 1090839026-Jun-14 7:45 
QuestionSoapUi Pin
Reginaldo Felix6-Jan-13 16:44
Reginaldo Felix6-Jan-13 16:44 
QuestionError in soap UI Pin
Ashay2722-Nov-12 20:45
Ashay2722-Nov-12 20:45 
Hi,

I am facing error while sending the req xml in soap ui.

<html><head><title>JBoss Web/2.1.3.GA - Error report</title> </head><body>

HTTP Status 403 -


type Status report

message

description Access to the specified resource () has been forbidden.


JBoss Web/2.1.3.GA

</body></html>


can u pls help me in this?
Questiondownload soapUI Pin
Alex Lewandowski2-Jul-12 4:10
Alex Lewandowski2-Jul-12 4:10 
AnswerRe: download soapUI Pin
Jobless Creature4-Jul-12 2:51
professionalJobless Creature4-Jul-12 2:51 
GeneralMy vote of 5 Pin
beibei200826-Jun-12 4:20
beibei200826-Jun-12 4:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.