How to Test Web Service using SOAP UI

How to Test Web Service using SOAP UI?

Table of Contents

Using SOAP UI, automated tests can be created for web services and Test Web Service using SOAP UI.

In this article, we will

  • Create a SOAP project using SOAP UI
  • Create Assertions in SOAP UI
  • Build an automated test using SOAP UI

First, you need to install SOAP UI from the URL https://www.soapui.org/downloads/soapui.html.

Create a SOAP project:

Step 1: Open SOAP UI.

Step 2: Press Ctrl + N to create a new project.

https://docs.mendix.com/howto6/attachments/18448632/18580339.png

Step 3: Run the project and go to http://localhost:8080/ws-doc/.

https://docs.mendix.com/howto6/attachments/18448632/18580314.png

Step 4: Enter the URL of WSDL in the field of Initial WSDL. The field Project Name will automatically get filled.

https://docs.mendix.com/howto6/attachments/18448632/18580334.png

Step 5: Click on, OK. It will then create a new project.

https://docs.mendix.com/howto6/attachments/18448632/18580313.png

Build a Test Suite, Test Case, and Test Step:

Step 1: Press Ctrl + T to create a new test suite.

https://docs.mendix.com/howto6/attachments/18448632/18580332.png

Step 2: Click on, OK. Select the name of your Test Suite and press Ctrl + N to create a new Test Case.

https://docs.mendix.com/howto6/attachments/18448632/18580331.png

Step 3: Click on, OK. Expand the Test Suite and Test Case. Right-click on the Test Step > Add Step > SOAP Request.

https://docs.mendix.com/howto6/attachments/18448632/18580312.png

Step 4: Enter the name of the step and click on, OK.

https://docs.mendix.com/howto6/attachments/18448632/18580329.png

Step 5: Select the option CustomerWebserviceSoap -> GetCustomers and click on OK.

https://docs.mendix.com/howto6/attachments/18448632/18580328.png

Step 6: Again, click, OK.

https://docs.mendix.com/howto6/attachments/18448632/18580327.png

Step 7: Open the SOAP request Retrieve Customers.

https://docs.mendix.com/howto6/attachments/18448632/18580326.png

Step 8: Change the value from

<Offset>?</Offset>
<PageSize>?</PageSize>

To 

<Offset>0</Offset>
<PageSize>10</PageSize>

Step 9: Press Alt + Enter to submit the request. The response will be:

<soap:Envelope xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="https://www.example.com/">
    <soap:Body>
        <tns:GetCustomersResponse>
            <Customer>
                <Name>Jessica D. Rogers</Name>
                <Address>2118 Collins Street</Address>
                <ZipCode>PA 16646</ZipCode>
                <City>Hastings</City>
            </Customer>
            <Customer>
                <Name>Jamie S. Wentz</Name>
                <Address>3269 Village View Drive</Address>
                <ZipCode>MD 20872</ZipCode>
                <City>Damascus</City>
            </Customer>
            <Customer>
                <Name>Blake G. Race</Name>
                <Address>4437 Sunny Glen Lane</Address>
                <ZipCode>OH 44115</ZipCode>
                <City>Cleveland</City>
            </Customer>
            <Customer>
                <Name>Angela L. Dolly</Name>
                <Address>3718 Alpha Avenue</Address>
                <ZipCode>TX 75439</ZipCode>
                <City>Ector</City>
            </Customer>
        </tns:GetCustomersResponse>
    </soap:Body>
</soap:Envelope>

Create Assertions:

Step 1: Click Assertions (1).

https://docs.mendix.com/howto6/attachments/18448632/18580307.png

Step 2: Click on the icon Add Assertion.

https://docs.mendix.com/howto6/attachments/18448632/18580324.png

Step 3: Click Property Content > XPath Match. Enter the expression count(//Customer) and click on Save.

https://docs.mendix.com/howto6/attachments/18448632/18580323.png

Extend your Test Case:

Step 1: Add a new Soap Request to the already available test cases.

FieldValue
Specify name for stepCreate Customer
Select operation to invoke for requestCustomerWebServiceSoap -> CreateCustomer

Step 2: Change the request.

<soapenv:Envelope xmlns:soapenv="https://schemas.xmlsoap.org/soap/envelope/" xmlns:exam="https://www.example.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <exam:CreateCustomer>
         <Name>Donald A. Hylton</Name>
         <Address>784 Better Street</Address>
         <City>Kansas City</City>
         <ZipCode>KS 66102</ZipCode>
      </exam:CreateCustomer>
   </soapenv:Body>
</soapenv:Envelope>

Step 3: Add a Contains Assertion and enter true.

https://docs.mendix.com/howto6/attachments/18448632/18580322.png

Step 4: Right-click on the test case, Retrieve Customers. Select the option Clone Test Step. Change the Test Step name to Retrieve Customers 2 and click on OK.

https://docs.mendix.com/howto6/attachments/18448632/18580320.png

Step 5: Open Test Step Retrieve Customers 2. Click on Assertions (2). Open XPath Match – Unknown. Change the Expected Result to 1+ and click on button Save.

Run the Test Case:

Open Test Case TestCase 1.

https://docs.mendix.com/howto6/attachments/18448632/18580310.png

Click on the icon Run this Test Case.

https://docs.mendix.com/howto6/attachments/18448632/18580309.png

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share this article
Subscribe
By pressing the Subscribe button, you confirm that you have read our Privacy Policy.
Need a Free Demo Class?
Join H2K Infosys IT Online Training
Enroll Free demo class