Building smoke test harness to test Webservices using SoapUI

We are currently working on a large enterprise integration project. The Integration is developed on a Services Oriented Architecture(SOA), where each application exposes itself as a Webservices. We finished our development cycle and when we migrated the code from development to QA environment, it was very difficult to make sure all the webservices are up and giving a valid response, there were close to 200 services. Mostly the test was done manually.

We went back to the drawing board and analysed how we can automate this. SoapUI, JUnit, Maven and Jenkins came to our rescue. The goals of this implementation is as below,

  • Build SoapUI projects to verify if the services is up and it is responding with meaningful message and we assert the response
  • Parameterizing/externalizing the host name, username and password so that we can run the tests on any environments
  • This can be even tested against live data/production system, hence we should never modify any real data
  • Having a easy web interface to test the interfaces

SoapUI project

  • Create a SoapUI project and Add WSDL (Ctrl U), Create Request and Create a Test Suite, Create Test case and Test Step
  • Bind the webservice method to the Test Step
  • Hardcode the test values to the Test step
  • Assert the response by Adding an assert
  • If the Webservice needs authentication, and if you want to parameterize the user name and password, you need pass ${#Project#username} and ${#Project#password}
  • Finally save the project

JUnit and Maven

You need to create a Maven/Java project and add the below dependency


In your junit class you need to write the below code,

public void testWebService() {
  SoapUITestCaseRunner runner = new SoapUITestCaseRunner();   runner.setProjectFile(soapUIProjectFile);
  String soapUIProjectFile = System.getProperty("soapUIProjectFile");
  String hostName = System.getProperty("hostName");
  String userName = System.getProperty("userName");
  String password = System.getProperty("password");
  if (hostName != null && hostName.trim().length() > 0) {
  String[] properties = new String[2];
  properties[0] = (password != null && password.trim().length() > 0) ? "pwd="     + password     : "";
  properties[1] = (userName != null && userName.trim().length() > 0) ? "username="     + userName     : "";
  return runner.getFailedTests();

Integrating with Jenkins

Create a new Maven Jenkins job, and parameterize the above 4 values as below,

mvn -DsoapUIProjectFile=${soapUIProjectFile} -DhostName=${hostName} -DuserName=${userName} -Dpassword=${password}

2 points to note,

  • Make sure these parameters soapUIProjectFile, hostName, userName, password are created in the Jenkins
  • soapUIProjectFile are checked in the same unit test project and the relative path of the SoupUI project is provided in Jenkins

That is all needs to be done, once it is in place, you just need to run the Jenkins project, it will prompt you with this information, if you pass the values, it will test the webservices in that environment.

We can also enhance this to,

  • Test all the projects in a folder in a recursive way
  • Get meaningful message from junit to inform how many webservices have passed and how many have failed and why they have failed

6 thoughts on “Building smoke test harness to test Webservices using SoapUI

  1. Sharath

    Are we hardcoding input data. This input data may not be valid when we test in different environment. How can we handle this? Also if we assume that input data is constant for all environment, web service response may differ. So how can we make our assert dynamic?

    1. Krishna Prasad Post author


      Ths objective of this exercise is very similar to JUnit testing. It will be constant accross the environment. For example if you send wrong types in webservices, you will always get type mismatch error. We will assert that as a positive test case.

      By asserting for this kind of exception, you make sure

      a. The Webservices is up
      b. The method exists
      c. The parameters in the methods have matched

      This type of test is not validating functionality. On the contrary we cannot test functionality in production environment, we will not get access to it.

      I hope I explained it correctly.

  2. sunnt

    Hi Krishan,
    Thanks for sharing this,
    I have one query here.
    See i have developed the some methods usign java and i am using those methods in our Soapui projects using groovy script step. and i placed the jar file in bin/ext folder… of soapui.
    when i run the soapui project thru maven i am getting error like jar file not fiund.
    how can i overcome this issue.

    Thanks in Advance.


    1. Krishna Prasad Post author


      Thanks for reading my blog. Search for that jar in if that jar exists, if it exists, add that dependency in the pom.xml and run it. It will work.

      If not let me what is the jar file, I can guide you.


  3. Vidya

    I would like to know if it is possible to pass part of response from previous step as parameter to the next step instead of harcoding test step parameters while running from testng/junit.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s