SOAP vs REST Services – Learn How to Create REST Project in SoapUI Pro – SoapUI Tutorial #13

In the previous tutorial, we discussed the features of SoapUI Pro and briefly touched about SOAP vs REST web services. This tutorial will give you SOAP (Simple Object Access Protocol) and REST (Representation State Transfer) based services and their advantages in detail.

=> Click here for the complete list of SoapUI and SoapUI Pro tutorials in this series.

Understanding REST and SOAP Services:

A web service is a program that helps us to connect two computers over the World Wide Web. Web services are the software component that supports machine to machine interaction over network. This is called interoperability which can be achieved by machine understandable format document called WSDL. WSDL is processed by SOAP and it transfers via HTTP in the form of XML.

soap vs rest services

Look at this pictorial representation of the web service flow.

SOAP vs REST Services 1

What is SOAP Service?

It is basically a protocol which has a set of defined rules to transfer the structured information implemented through web services. SOAP uses XML format data which is platform independent so it can support all the major protocols such as HTTP, FTP, TCP, and UDP and so on.

SOAP services follow the standards for sending and receiving message with the unique format. Usually SOAP message contains the following information:

  • Request / Response Data
  • action to be performed
  • Header information
  • Error details if any failure messages

In SOAP, security related services given by WS-Security standards are in both the client and server side. WS-Security offers data integrity and privacy. WS-ReliableMessaging is another feature that provides end to end reliable services for success and failure cases.

WSDL is the major technique for handling SOAP service information.

What is REST (Representational State Transfer)?

It is architecture based specially designed for networking applications and is used in client-server systems to send request and response. REST services are also called as RESTful APIs as it is implemented by using Hypertext Transfer Protocol (HTTP). It is GUI independent, and we can test REST APIs using SoapUI without the actual application. It follows a stateless method which means, whenever the client sends the request to the server, server does not store any data in the session.

SOAP vs. REST

  • SOAP is a protocol and REST is architecture. It allows us to send SOAP envelops to REST based applications.
  • REST supports different message formats but SOAP permits XML only.
  • REST services are faster and easy to handle.
  • SOAP is tied with SMTP and HTTP protocols whereas REST relies on HTTP only.
  • SOAP is more secure and structured format.
  • REST does not depend on any specific standards as it supports various messaging formats like JSON, CSV and XML.
  • SOAP web services allow us to build the client with RESTful services.
  • SOAP was introduced for distributed computing.
  • After REST’s entry, it accommodated the web by its performance and scalability as it is a light weight component.
  • REST is stateless whereas SOAP is a state-ful specification.
  • REST uses Uniform Resource Identifier (URI) and it has the methods like GET, PUT, POST and DELETE to expose their resources.
  • SOAP uses named operations and interfaces to achieve its business logics.

Now let us discuss REST services by creating REST project in SoapUI Pro.

Creating REST Project in SoapUI Pro:

Follow the below steps:

1) Open SoapUI Pro application and right click on the Projects node present in the Navigator panel

2) In the context menu, click New REST Project option

3) Enter the following Google Map API location in the given text field: http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false

4) On OK, SoapUI Pro will create project tree along with resources, service, methods, and endpoint with input request in the editor. See below:

(Click image for enlarged view)

SOAP vs REST Services 2

5) As you can see in the above screenshot, there is a parameters section. If you click on it, it will show you the parameters that are used in the service in a separate popup window.

------------

6) Now let us execute this service by clicking on the Run properties with groovy Script icon. SoapUI Pro generates the following output for the given endpoint in the form of XML.

(Click image for enlarged view)

SOAP vs REST Services 3

We are done with functional testing for Google Map API. Let’s add test suites and test cases to get to know more about REST services.

To add test case, do the following:

1) Click on the SOAP vs REST Services 8 icon to add test case request

2) Enter the test suite name and then click OK

3) Then provide the test case name and click OK button

4) In the Add Request to Testcase dialog, enter the request name and then click OK button

5) Now the test suite tree will look like this.

SOAP vs REST Services 4

6) Run the test suite by double click on the test suite name

7) Here is the test suite results

SOAP vs REST Services 5

8) To get the test results report, click on the SoapUI pro features 12 icon from the tool bar.

10) In the Create Report window, make sure the format is selected TestSuite Report

11) Or else you can use JUnit-Style HTML Report format

12) Click OK button and verify the results

SOAP vs REST Services 6

Similarly, we can add REST services, resources and methods. As we discussed we can have any number of resources in the resource path.

Let us start with adding REST service:

SOAP vs REST Services 7

Difference Between SOAP and REST services:

Now you know how to add REST resources. Here I have summarized the differences between SOAP and REST services.

SOAPREST
SOAP is abbreviated as Simple Object Access ProtocolREST stands for Representational State Transfer
It is basically XML based message transfer protocolREST is standard architecture to build web services.
Request and Response data are used in the form of XMLREST service request and response data can be JSON, CSV and XML
It is complicated whenever the WSDL file is changed because we need to re-generate WSDL to build the client accordingly.We can use REST APIs without disturbing the existing client.
SOAP is tied with HTTP and SMTP protocolsREST relies on only HTTP
Do not have built-in error handlerSupports error handler for identifying the faults during run-time
SOAP messages cannot be cached when it readsREST data can be cached

Conclusion:

So far in this tutorial, we learned SOAP and REST services and their advantages and differences.

We can also add assertions for the REST services to assert our services. We can add any number of REST test steps and transfer the data between each with the property transfer.

In the next SoapUI Pro tutorial, we will see Data Driven Testing. Please let us know your comments and questions below.

Recommended reading

7 comments ↓

#1 Sanjeev kumar

which is better soap or rest? why?

#2 Karunagara Pandi

@Sanjeev kumar: For performance, usability wise REST services better and security purpose SOAP can be used.

#3 kirti

thank you for sharing. this is very good article
I want to know what is RESTFul Web Services

#4 Gaurav Khurana

Could you please continue the series for REST and go a little bit more details if possible .. thanks for sharing..

#5 Nima

Hi Team,
Im really interested in learning Ziggy to test REST services.DO u guys have ny supporting article?I hardly can find related articles in internet also.Please let me know some information

Thanks
Nima

#6 Lee

How can we use this to email test results?
thanks Lee

#7 Megun

Good article

Leave a Comment