SoapUI
What is SoapUI? Introduction to SoapUI Testing
What is SOAP UI? SOAP UI is the leading open source cross-platform API Testing tool SOAPUI allows...
Web Services is the mechanism or the medium of communication through which two applications / machines will exchange the data irrespective of their underline architecture and the technology.
Web Services Testing is a type of software testing that validates Web services. The purpose of Web Services Testing is to check the functionality, reliability, performance, and security of an API(Application Program Interface). Web Service Testing is similar to unit testing in some cases. You can test a Webservice manually or create your own automation code or use an off-the shelf automation tool like Postman.
In general, software applications are developed to be consumed by the human beings, where a person sends a request to a software service which in-turn returns a response in human readable format.
In the modern era of technology if you want to build a software application you don't need to build each and everything from scratch. There are lots of readymade services available which you can plug into your application and you can start providing those services in your application.
For example you want to display weather forecast information you don't need to collect, process and render the data in your application. You can buy the services from the people who already well-established in processing and publishing such kind of data.
Web services allow us to do these kind of implementations.
As an example, consider the following WebService
http://www.webservicex.net/stockquote.asmx?op=GetQuote
It gives Share Value for a Company.
Let's find share price for Google (Symbol: GOOG )
The response XML gives the stock price.
This WebService can be called by a Software Application using SOAP or HTTP protocol.
Web Services can be implemented in different ways, but the following two are the popular implementations approaches.
SOAP is a standard protocol defined by the W3C Standard for sending and receiving web service requests and responses.
SOAP uses the XML format to send and receive the request and hence the data is platform independent data. SOAP messages are exchanged between the provider applications and receiving application within the SOAP envelops.
As SOAP uses the simple http transport protocol, its messages are not got blocked by the firewalls.
REST means REpresentational State Transfer; it is an architecture that generally runs over HTTP. The REST style emphasizes the interactions between clients and services, which are enhanced by having a limited number of operations. REST is an alternative to SOAP (Simple Object Access Protocol) and instead of using XML for request REST uses simple URL in some cases. Unlike SOAP, RESTFUL applications uses HTTP build in headers to carry meta-information.
There are various code that REST use to determine whether user has access to API or not like code 200 or 201 indicates successful interaction with response body while 400 indicates a bad request or the request URI does not match the APIs in the system. All API request parameters and method parameters can be sent via either POST or GET variables.
Rest API supports both XML and JSON format for WebServices API Testing. It is usually preferred for Mobile and web apps as it makes app work faster and smoother
WSDL (Web Services Description Language) is an XML based language which will be used to describe the services offered by a web service.
WSDL describes all the operations offered by the particular web service in the XML format. It also defines how the services can be called, i.e what input value we have to provide and what will be the format of the response it is going to generate for each kind of service.
To test web service, you can
Web Services Automation Testing involves following steps -
Suppose we want to test web service which provides Currency Conversion Facility. It will the current conversion rates between the different countries currency. This service we can use in our applications to convert the values from one currency to the other currency.
Now lets look at above steps
Currency Convertor WSDL file can be seen @ (http://www.webservicex.net/CurrencyConvertor.asmx?wsdl) which will give the information about the Currency Convertor web service methods which it will support, the parameter which we need pass and the type of parameters… etc
There are lots of WebService Test tools available to test SOAP web service. SoapUI is one of the popular API tool which will help us to test SOAP web services. In fact you can use the any programing language which is capable of sending the XML request to the web service provider application over the http and able to parse and validate the response XML against the expected result. In this Web Services Testing tutorial, we will test the WebService
Generally web service takes the request and sends the response in the XML format.
Apache Axis2 API project is a Java implementation API, which will be used to create the Web services for both server side (service provider) and client side (service consumer).
Axis2 is capable of sending SOAP messages and Receives & Processes the SOAP messages. We can write a small Java program using the API to create the web service. Axis2 will generate the WSDL from Java program which will be used to communicate the services offered by the web service. We can use the same Axis2 to generate the Java class (stub) from WSDL file which we can use as a client program to generate the web service request, to send the request to the service end point and to process the response.
Let's look at above steps in detail
Step a) Download the axis2 API @ https://axis.apache.org/axis2/Java/core/download.cgi & Set the environment variable 'AXIS2_HOME'
Step b) Create a folder to keep all the generated artifacts
Ex : C:\Axis\Projects\CurrencyConverter
Step c) Open the command prompt and navigate to the folder structure where you want to generate the artifacts and Run the following command which will generate the stubs
%AXIS2_HOME%\bin\WSDL2Java -uri http://www.webservicex.net/CurrencyConvertor.asmx?wsdl -p org.apache.axis2.currencyconvertor -d adb –s
Step d) Once the command is successfully run, you will see the folder with required files.
Step e)In the next step of this Web Services Testing tutorial, we have to create the client program, through which we will send the actual request using the generated stubs. Open the eclipse and create the new Java project and select the folder which we have created above.
Step f) Add all the axis2 related jars to project build path, which will be there in lib folder of the axis2 software folder
(for ex : C:\Axis\axis2-1.6.2\lib)
Step g) Create a new Java class (ex : Client.Java) and instantiate stub object. Using the stub object we can call all the supported methods of the particular WebService.
Client.Java Program package org.apache.axis2.currencyconvertor; import org.apache.axis2.currencyconvertor.CurrencyConvertorStub.ConversionRate; import org.apache.axis2.currencyconvertor.CurrencyConvertorStub.ConversionRateResponse; import org.apache.axis2.currencyconvertor.CurrencyConvertorStub.Currency; public class Client { public static void main(Java.lang.String args[]) { try { //Create the stub object by passing the service end point url CurrencyConvertorStub stub = new CurrencyConvertorStub("http://www.webservicex.net/CurrencyConvertor.asmx"); //ConversionRate is the class which we have to use mention the from and to currency //ConversionRate object will be the parameter for the conversionRate operation ConversionRate conversionRate = new ConversionRate(); conversionRate.setFromCurrency(Currency.USD); conversionRate.setToCurrency(Currency.INR); //Create the ConversionRateResponse object, which is going to be used to catch the response //call the conversionRate service using the stub object ConversionRateResponse conversionRateResponse = stub.conversionRate(conversionRate); //We can use the conversionRateResponse object to retrieve the response of the ConversionRate Service System.out.println("Conversion Rate from INR to USD : " + conversionRateResponse.getConversionRateResult()); } catch (Exception e) { e.printStackTrace(); } } }
In SoapUI
As you may conclude, usage of WebService Test tools like SoapUI expedites your Web Services Automation Testing Effort. Hence SoapUi will be focus of our learning in the succeeding tutorials.
What is Difference between WebService and WebAPI?
Web Service | Web API |
|
|
|
|
|
|
|
|
Learn more about Web API Testing
This Web Services Testing tutorial is made possible with contributions of Mr. Narender Reddy Nukala
What is SOAP UI? SOAP UI is the leading open source cross-platform API Testing tool SOAPUI allows...
1) Explain what is SOAP UI? SOAP UI is a free, open source cross-platform functional Testing...
Download PDF 1) Explain what is REST and RESTFUL? REST represents REpresentational State Transfer;...
SoapUI is a widely popular API testing tool. It allows you to test REST and SOAP protocols. It...
Understanding the SOAP Protocol Before we create a SOAPUI Test case, let us understand basics...
In this tutorial, we will demonstrate the steps to download, Install and Configure SOAP UI (Open...