Sunday, July 25, 2010

SoapUI-A quick start guide





Overview  

soapUI is an Open Source Web Service Testing Tool for Service Oriented Architecture. There is also a Pro version that is released as a commercial product. We will be using the free Open Source Version for our web services testing.This document should guide you to quickly install soapUI and test your web services.

Installation  

1) Download the open source '''standalone version''' of soapUI from the following URL from the available downloads.The standalone version comes with the required JRE for the soapUI to run.

SoapUi

There were instances where the Internet Explorer crashed while downloading soapUI.Use firefox or some other browser if you have issues using Internet Explorer.

2)Extract the contents of the zip file to a location on your machine.

WSDL File

WSDL stands for Web Services Description Language and is the contract between a service provider and the consumer.All you need is a wsdl file url to get started.Typically a developer provides the URL to the web service endpoint.

Creating a SoapUI Project  

1)Launch soapUI by double clicking on the soapui.bat under the following directory.

 <soapUI installation directory>\bin

2)From the file menu select ,new soapUI Project.

3)Type in the project name and enter the wsdl url.

4)Select the following options
    Create sample requests for all operations
    Creates a TestSuite for the imported WSDL
  
5)On the Generate TestSuite dialogue you can choose the options as required or pick the defaults.Enter the name for your TestSuite.You can always rename this later.soapUI generates the required tests and organizes them in to TestSuites,Test Cases and Test Steps.
Expand the TesSuite and browse to the Test Steps

6)From the file menu select the save all projects option and enter the filename.soapUI saves the projects as an xml file.

Running your Tests  

You can run the tests by clicking on the play button at a test case level or a test step level.

You can add new test steps and modify the request/data as required by righclicking on Test Steps.
 Test Steps-->Add Step-->Test Request

Authentication/User Name Token

WS-Security Username Token technique-This consists of a Soap header containing the userid and password. This technique ensures that the Soap message contains the correct header, and validates it against the LDAP directory. The user receives a SOAP fault if authentication fails.

To add the username token data to your request.From the example below copy the wsse namespace to the soap envelope element.Add the username token header as shown below and  replace the username and password with the appropriate values.

Warning: Do not copy paste the Envelope element as you might loose other namespaces specific to your request.

example:

<pre>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
   <soapenv:Header>
      <wsse:Security>
         <wsse:UsernameToken>
            <wsse:Username>username</wsse:Username>
            <wsse:Password>password</wsse:Password>
         </wsse:UsernameToken>
      </wsse:Security>
   </soapenv:Header>
</pre>


Editing the wsdl URL  

While you switch from an environment/server to another you can update the url for the endpoint from the testcase/step editor.From the address bar on the test step you can select the edit option and update the URL.

Mock Services  

soapUI allows you to create a Web Service Simulation of the imported WSDL.This is very helpful especially with the Contract/WSDL first development where a tester can write/run the tests against the mocked service instead of waiting for the developer to complete the actual implementation.

Load Testing  

soapUI allows you to create/run load tests using different criteria.To create a load test,right click on the Load Tests option under your TesCase and select New LoadTest.Enter a name and choose the options you want to fire a load test.

You can also do this right at the project creation time, by selecting the check box 'Generate a default LoadTest for each TestCase' on the Generate TestSuite Dialog.

Additional Resources  

http://www.soapui.org/


Related Articles:


Web Services Overview For Everyone

WSDL Explained


Web Service Standards