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.

Look at this pictorial representation of the web service flow.

What You Will Learn:

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:

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

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)

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  icon. SoapUI Pro generates the following output for the given endpoint in the form of XML.

(Click image for enlarged view)

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  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.

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

7) Here is the test suite results

8) To get the test results report, click on the  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

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:

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.