This is my first ever experience of writing a blog. Here I am trying to demonstrate SoapUI, the most popular tool for API testing using real time example. Let's see how to install and use SoapUI to test web services.
What is an API?
API - Application Programing Interface is a mechanism that enables two software programs to communicate with each other using a set of definitions and protocols. For example, Alexa uses API to interact with the weather department's software system which contains daily weather data. This is how Alexa is able to get weather details and respond to weather related questions.
Now Understand SoupUI
SoapUI is the open source and most advanced testing tool for SOAP (Simple Object Access Protocol) and REST (Representational State Transfer) based web testing. It is Java based tool, so it runs on most operating systems like Windows, Mac and Linux.
To run your first Soup Project in SoupUI tool:
SOAP projects can be created from a WSDL file.
You can continue with Simple Calculator project to run a test.
Go to www.soapui.org and click download SoapUI Open Source. It's available for Linux, Windows and Mac operating systems. I am using Windows laptop for Installation.
You will get a SoupUI.exe file, double click on .exe file and installation wizard will be there:
Continue with "Next" button until installation is complete with default settings. Once you click on finish, it will start SoupUI. Also, it will create a new icon on your desktop. So, your SoupUI can be launched with just a click on the icon.
Example-1: Calculator API
To create a soap project we need a WSDL link. WSDL stands for Web Services Description Language. It will be available in XML format that describes a web service. We will be using this sample WSDL Link : "http://www.dneonline.com/calculator.asmx?wsdl" .
Let's see how to create a new project in SoupUI:
Double click on SoupUI icon to launch the tool and close all the pop-ups.
Click on File -> New Soup Project or you can directly click on SOUP icon.
Now copy and paste WSDL URL: "http://www.dneonline.com/calculator.asmx?wsdl" in the Initial WSDL field:
"Calculator" name will be displayed in Project Name field.
Select default setting and continue by pressing OK.
SoapUI will load contents of Calculator Project with it's properties:
Select "Add" option and double click on Request 1, which opens the following window:
Enter two whole numbers in the place of "?" and press the green arrow on the top left side of Request window.
The response will be returned in RAW format. Click on XML button to see the response in XML format.
RAW format response:
XML format response:
Error will be displayed like this, if you entered a wrong input:
We have to find the WSDL link from the given URL:
Follow the same previous steps to RUN test in SoupUI. Insert the input in the request window and get the result in the response window.
#1. Copy and paste the given link in browser and you will get the webpage where you can find the WSDL link under "SPECS" section.
#2. Now create a new project by using the WSDL link :
#3. Now we have to figure out what input should take the place of the "?". Let's look into the web service description. BLZService is a simple German Banking Code lookup service. It uses SOAP protocol and responses are formatted in XML. The is little documentation aside from the WSDL. The main site is in German.
From the description we can understand that it is about German Banking Code. For further details you can Google BLZServices and find out about the BLZ code. It is a numerical code used to identify an individual branch of a financial institution in Germany. You can search up a list of BLZ codes used in German Banking Services. it's an 8 digit code.
#4. Now replace the 8 digit number as an input in place of the "?". You will get the corresponding bank details in the response window. Since it will be in RAW format, click on the XML button on the response window to see the XML format.
This way we can run tests for other BLZ codes too. There is a long list of inputs, so multiple inputs can be tried.
If a wrong BLZ code is entered, an error message will be shown.
This is my first learning experience of API, and I hope as a beginner, you also learned something significant from this blog. Thanks for reading and don't forget to share your thoughts on this blog too. See you next time with a new topic!
- Neha Patel