Understanding the SOAP Protocol

Before we create an SOAPUI Test case, let us understand basics about the SOAP Protocol. This will help you use SOAP UI to test SOAP requests and response effectively.

SOAP stands for Simple Object Access Protocol. Below are the properties of a SOAP Protocol.

  • It is an XML-based protocol for communicating between two different systems.
  • It is a platform and language independent. Hence, a system developed using Java can communicate with a system developed in.NET.
  • SOAP requests/response are transported via HTTP.

In this tutorial we will learn

Learn the SOAP Message FORMAT

Create a Project

Creating Test Suite

Creating Test Case

Test Step Insert

Understanding the Soap Response & Log Panels

Sending Request Manually & Reading Response

Learn the SOAP Message FORMAT

A SOAP message is an ordinary XML document containing the following elements. Message can be either a request message or a response message.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

After setting up the workspace which we had performed in the last tutorial, we have to create projects, test suites, test cases in order to test a given web service. Let us understand the steps involved in doing the same.

Create a Project

Step 1: Now depending upon the project, we need to import SOAP/REST protocol. We will create a new SOAP Project.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 2: We will make use following SOAP request

http://www.webservicex.net/CurrencyConvertor.asmx?WSDL

  1. Enter the Project Name
  2. Enter the path of the WSDL request. In this case http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
  3. Click OK

Note:

  • Upon checking – Create sample request for all operation' creates a sample request for all the available operations in the given WSDL. As soon as you enter the WSDL address, this option is checked automatically. You may uncheck it.
  • Upon checking – Create, a Test Suite for the imported WSDL' creates a test suite within the project for the imported WSDL.
  • Upon Checking – Relative Path' enables the user to save all the files relative to the project file.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 3: Upon creating the SOAP project with the above-said WSDL, we will be able to see that there are two operations that will be imported into the project.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 4)

  1. Expand the first request and double click on the 'Request1'. It will display the SOAP request in the XML format.
  2. Enter the From Currency and To Currency
  3. Click on the submit button
  4. Response XML will be displayed right side pane.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

You may wonder why create Test Cases? When you can directly test WebService here…

Well, you can send a request for one operation. What about others? How many combinations of FOREX conversion you can do using this operation. You have to edit the request for each and every combination.  

For example: If you want to convert from GPB to INR instead of USD to INR… You need to edit the operation again. So, one has to create a test suite/cases to have all possible scenarios tested without having to directly edit the operation itself.

Creating Test Suite

Step 1: Within the project, testers can create a test suite by performing a right click on the root of the project.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 2: We need to enter the name of the test suite and press OK.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 3: The created test suite is displayed the navigator pane as shown below.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 4: The test Suite window opens in the Right Pane. As we have just created there are NO test cases. Hence all options are disabled.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Creating Test Case

Step 1: Within a test suite, we can create multiple tests by performing right click on the 'test suite' and choosing 'New Test Case'.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 2: Specify the name of the test case and click 'OK'.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 3: The created test case has zero steps as shown below.

Note: We can see that the test case is added with zero test steps for all kinds of tests available. Upon adding the test steps the numbers in the bracket would change automatically. The functional test step

SoapUI Tutorial: Create a Project, Test Suite, TestCase

should go into 'Test Steps' while a performance test step should go into 'Load Test' and a security test step should go into 'security Tests'.  

Step 4: We can insert a variety of test steps by performing a right click on test steps and selecting an appropriate test step as shown below. So if you were to test a REST WebService, you would select the REST Test Request.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Test Step Insert

 

Now let us add a test step to validate the imported SOAP request.

Step 1: Add a new step 'SOAP Test Request' as shown below.

SoapUI Tutorial: Create a Project, Test Suite, TestCase  

Step 2: Enter the step name and click OK.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 3: Upon clicking 'OK', a dialog pops up to select the operation to invoke. All the operations are listed, and user can select the operation that they would like to invoke.

  • There are two operations that will be listed. Both the Operations are the same except the SOAP version used.

    CurrencyConvertorSoap – uses SOAP version 1.1 where as,

    CurrencyConvertorSoap12 – uses SOAP version 1.2

  • The Version does not matter for us in this context. Hence you can select the one of your choice.

    SoapUI Tutorial: Create a Project, Test Suite, TestCase

  • Upon Selecting the operation, click 'Ok'

    SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 4: While adding a test case, we can add standard assertions. Assertions also called as checkpoints/validation points which we will be dealing in detail in the next tutorial.

We can add following checkpoints/assertions while creating test case. Let us create a test case with the default option which means creating test step WITHOUT any of the below validation points

  • Verifies if the response message is SOAP, upon executing the test.
  • Verifies if the response schema is valid.
  • Verifies if the SOAP response contains FAULT.

    SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 5: Upon creating the test case, the request XML is shown below. The structure of the XML is explained within the below snapshot.

SoapUI Tutorial: Create a Project, Test Suite, TestCase  

Step 6: The test step count is now incremented to one as we have just added one test step. Similarly upon adding load and security tests step, the corresponding number would be automatically incremented based on the number of steps added.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Send Request Manually & Reading Response

Step 1: We would like to convert the currency from USD to INR.

  • FromCurrency – USD
  • ToCurrency – INR

Next,

  1. We need to enter these inputs in place of the question mark which will be sent as request XML.
  2. After inputting those values into the corresponding XML tags, click 'submit request' button to check the response.


SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 2: Upon submitting a request the web service request is processed by the webserver and sends back a response as shown below.

By reading the response, we are able to conclude that 1 unit of USD = 63.525 units of INR.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Understanding the Soap Response & Log Panels

As explained at the beginning of this tutorial the SOAP messages are transported via HTTP protocol. Let us take a look at the RAW messages. This will help us learn how the SOAP request and response were transported by HTTP.  

Step 1: Click 'RAW' Tab in both SOAP-UI request Window.

  1. The Request is posted to the webserver. Hence, the POST method of Http is used.
  2. The SOAP Request is transported in the body of the Http message as shown below
 

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Step 2: Now click 'RAW' Tab in SOAP-UI Response Window to understand how the response is sent via HTTP.

  1. After processing the request, the Http response code (200) is shown which means it is a success. The webserver has processed it successfully.
  2. The SOAP response is sent back to the client as part of the body of the HTTP message.

SoapUI Tutorial: Create a Project, Test Suite, TestCase  

A Quick snapshot of the Http Response codes for easy understanding and debugging. The below table will help you to trouble shoot based on the HTTP code received from the webserver.  

Http Code

Description

1xx:

Informational - This means a request received and continuing process.

2xx:

Success - The action was successfully received, understood, and accepted.

3xx:

Redirection - This means further action must be taken in order to complete the request.

4xx:

Client Error - This means the request contains bad syntax or cannot be fulfilled

5xx:

Server Error - The server failed to fulfill an apparently valid request

 

Step 3: Let us understand the other information that are displayed in the test case window.

  1. Represent NO header in the request that is being sent
  2. Represents NO attachments in the request that is being sent to the web server.
  3. Represents 12 header information and the same are displayed upon clicking on it.
  4. Represents that there are no attachments from the response message.
 

SoapUI Tutorial: Create a Project, Test Suite, TestCase  

LOGS PANE:  

Logs pane has the complete information regarding the transaction between the client and the server. Users will be able to see the tabs of the Log pane as shown below. We will discuss the most commonly used log panes when working with SOAP-UI.  

SoapUI Tutorial: Create a Project, Test Suite, TestCase

SoapUI Log – Displays the response information from webserver. The same information is stored in soapui.log file of the SOAP-UI installed folder under 'bin' directory.  

SoapUI Tutorial: Create a Project, Test Suite, TestCase  

Http Log – Displays all the HTTP packet transfer. All the information in 'RAW' is shown in HTTP log.

SoapUI Tutorial: Create a Project, Test Suite, TestCase

Error Log – Error log displays all the errors that we have encountered during the entire project session. The same information is available in 'soapui-errors.log' present in the 'bin' directory of the SOAP UI installed location.

Memory Log – This tab monitors the memory consumption and displays it in the form of the chart as shown below. It is really helpful when there is a memory intensive operation is performed.

SoapUI Tutorial: Create a Project, Test Suite, TestCase  

Now that we have created test suite, test case, test step and got a response, next step is to validate the response. We will deal with types of assertions in the next tutorial.