How Do You Test a SOAP and REST Service?

Table of contents

REST and SOAP are two critical web services technologies that revolutionize how businesses use APIs. Since APIs are so common, it's important to test them regularly to find vulnerabilities or potential operating problems within the web service.

Testing a SOAP web service or a REST web service can seem daunting, but various platforms help you properly monitor and test your API solutions. Before going through the technical process of testing a web service, it's worth taking the time to understand the basics of SOAP and REST APIs and some other essential terms.

This article will explain SOAP vs. REST, how to test SOAP and REST web services, and show you some of the top SOAP and REST testing tools available for your use today.

Here are 5 things to know about SOAP and REST testing:

    • SOAP (Simple Object Access Protocol) and REST (Representational State Transfer) are two primary web service communication protocols that require regular testing to ensure optimal functioning and security.

    • Various tools like Postman for SOAP and SoapUI for REST are available to facilitate the testing process, providing a user-friendly interface and clear analysis of responses.

    • In SOAP testing, you input the service URL, set the request headers, include body data, and send a request. You then analyze the responses for any errors or discrepancies.

    • REST testing, on the other hand, uses various HTTP methods such as GET, POST, PUT, and DELETE. Each method performs a different function in the request-response cycle, and testing ensures these are working as expected.

    • Both SOAP and REST services can be subjected to automated testing, making it more efficient to identify and fix potential issues.


What is SOAP?

SOAP stands for Simple Object Access Protocol. Microsoft originally came up with SOAP to facilitate messaging services on the internet. It uses XML exclusively for sending and receiving data. When SOAP was first released, reliance on XML was a big reason to adopt it as a standard. Since XML is a text-based language well-supported on all major platforms, it was a perfect fit for sending data via APIs.  

After the initial release of SOAP, Microsoft handed over development and maintenance to the Internet Engineering Task Force (IETF), where it eventually became a web standard. As the first popular web service, a long list of protocols and standards have been developed for use with SOAP, most of them starting with the initials WS (Web Services). One of the most important is WS Security, the security protocol that secures SOAP transmissions.  

Developers tend to like SOAP's built-in error handling. If there's a problem with a SOAP request, a detailed error message is sent in response to help troubleshoot the issue. There is a standard list of error codes used, which can be used to automate error handling in code.  

SOAP is primarily associated with HTTP, the web protocol native to all modern platforms. It can also be used with other internet protocols, such as SMTP.   While SOAP has had a long run as a widely-used protocol, over time, developers started to want something more flexible. Not all programming languages are good at exporting the required XML needed to make a SOAP request, creating the need for a protocol that can use other messaging formats.

What is REST?

The need for more flexibility in web services developers to create several alternatives. Today, REST is the most popular. REST stands for Representational State Transfer, and it is now the default choice for the majority of APIs. Unlike SOAP, REST is not exclusively dependent on the use of XML. The most commonly used language with REST is JSON.  

REST gives developers a broad architectural framework to work from. It usually just relies on a simple URL for sending information. Through the URL format, REST can use common HTTP 1.1 tasks like GET, POST, PUT and DELETE to accomplish tasks. REST supports HTTPS but without the stringent security requirements of SOAP.  

Developers call APIs that comply with REST standards RESTful APIs or simply REST APIs. DreamFactory is a REST API-as-a-service platform. We help companies build and manage secure REST APIs and monitor and test their solutions.

Testing SOAP Services

Each SOAP web service testing tool may use a slightly different approach, but here we will use Postman to demonstrate the basic steps for testing a SOAP service.   

Once you have downloaded the app, you will want to open a new request tab by pressing the New button in the upper left corner of the screen and entering a name to save the file. 

SOAP and REST Testing: Creating a new request

Step 1: Entering the URL

Once you have opened the new request tab, Postman will show you an address field where you can enter the URL. Postman offers a simple example for testing: https://postman-echo.com/get. You can also try anything in their list of free and public SOAP APIs. This permits you to enter a SOAP endpoint URL to make a request.   

SOAP and REST Testing: Selection of Correct verb

Then you will have to choose what type of request you want to make. There is a drop-down menu from which you can choose GET, POST, PUT, PATCH or DELETE. Postman’s default is GET. For the purpose of this test, select POST and use this URL: 
https://www.dataaccess.com/webservicesserver/NumberConversion.wso.

Step 2: Including Body Data

At the top of the request tab, there are several subsections including Params, Authorization Headers, Body, Pre-request Script, Tests and Settings. Under the Body tab, choose raw. 

SOAP and REST Testing: Selection of Body

There is also a drop-down menu offering Text, JavaScript, JSON, HTML and finally XML. SOAP always uses XML. 

SOAP and REST Testing: Selecting XML language

You will now be able to enter your XML. Any such entry must include the Envelope, Header and Body tags. You must also include any namespaces, the name of the operation and the values you want to post. 

Step 3: Setting Request Headers

Postman automatically adds a content type header. The default is application/xml. You will have to check your SOAP service to know whether you need to use application/xml or if you should change it to text/xml. To do this, open the Headers tab next to the Body tab and view your hidden headers.  

To do this, open the Headers tab next to the Body tab and view your hidden headers. 

SOAP and REST Testing: Revealing hidden headers

Then you have to deselect the Content-Type header, which is the default addition and add a new row with Content-Type in the Key column and text/xml in the Value column. 

SOAP and REST Testing: Content Type and Text/xml

Step 4: Send Your Request

Now you simply have to press Send. If the action is successful, you can see the response in the lower tab as shown below.

SOAP and REST Testing: 200 OK response from SOAP testing

You have finished testing your SOAP service. For some further testing, you can also perform schema validation in Postman. This will ensure that your XML syntax is correct and that all tags are properly opened and closed.  

Testing REST Services

As with SOAP, there are a lot of options for REST testing. The processes may vary depending on the tool you use, but we will use SoapUI as the API testing tool in this example. Despite its name, you can utilize SoapUI for either SOAP or REST web services. It is perhaps the most commonly-used solution for REST services testing.    

Like Postman, SoapUI is also open-source. You can download the tool for free here. After downloading, follow the installation directions. Once SoapUI is up and running, open your file. These are the steps for creating a REST project using the GET method from an endpoint.

Step 1: Creating the Rest Project

SoapUI offers several different ways to get started. SoapUI automatically opens a REST dialog on startup that you can then use to work without creating a new project. You can disable this, however. The second is to click the folder icon marked REST in the upper left of your screen, opening your New REST Project dialog box. The third is to click Projects in the navigation panel and select New REST Project. The fourth is to use hotkeys. On Windows, the hotkey combination is CTRL+ALT+N, while in Mac OS it is CMD+ALT+N. Finally, you can simply press New Rest Project on the start page. 

SoapUI showing new REST project

SoapUI offers several different ways to get started. 

    • SoapUI automatically opens a REST dialog on startup that you can then use to work without creating a new project. You can disable this, however. 

    • The second is to click the folder icon marked REST in the upper left of your screen, opening your New REST Project dialog box. 

    • The third is to click Projects in the navigation pane and select New REST Project. 

    • The fourth is to use hotkeys. On Windows, the hotkey combination is CTRL+ALT+N, while in OS X it is CMD+ALT+N. 

    • Finally, you can simply press New Rest Project on the start page. 

The result is that a box opens up for you to enter the URI. Using the URL that SoapUI offers for testing, https://petstore.swagger.io/v2/pet/findByStatus?status=available, will let you get started. 

New REST project naming screen with Petstore swagger link.

Now click OK. SoapUI automatically chooses a default Method (GET). The result will include a Service, Resource and Request.

Step 2: View the Response

You have made your first project and should now see the Request editor pictured below. Simply clicking the Green Play Button in the top left corner of the screen (indicated by the red arrow) will let you view the response in the right panel. The default is XML, so you will need to select the tab that correctly describes the language of your service. The options are XML, JSON, HTML or Raw. For this example you will select JSON, which is the most common for REST APIs. 

SOAP and REST Testing: JSON Selection in Response

Step 3: Create a Test Case

In your left navigation pane, right-click on Request 1. Then choose the Add to TestCase option. Alternatively, you can simply use the hotkey combination CTRL+ALT+A. 

SOAP and REST Testing: Creating a Test Case

You may need to create a new TestSuite simply by entering the name in the window that comes up and click Accept. You will also need to specify the TestCase name and set your specifications for adding the request to the TestCase. 

SOAP and REST Testing: Creating a Request Window

The TestCase window will open. Press the Green Play Button again to view your response. You can then create your assertion. 

Step 4: Create Assertion

With the TestCase window maximized, click on the Assertions tab as shown below and select the green plus symbol that appears to add the assertion. 

Under the Property Content tab, click the Contains assertion and click Add. 

SOAP and REST Testing: Creating an Assertation

A new window will appear. In this case, we must verify that ‘Petstore’ is present by entering it in the content box and pressing OK. 

SOAP and REST Testing: Verification in SoapUI

You can see your new project and the web service operations available for your API in the Navigator. Double-click the name of the project or service to get an overview of each. 

For performing deeper testing, take a look at SoapUI's extensive documentation

Dreamfactory also helps with API testing and monitoring as a comprehensive REST API management platform. 

SOAP and REST Testing Tools

Several apps and services are available for SOAP and REST testing. Here is some additional information on four of the top options for SOAP and REST API testing. 

    1. SoapUIAs we mentioned in the REST tutorial, SoapUI is an open-source tool. Smartbear developed the software. Businesses use it to perform functional testing, load testing, advanced mocking, and API monitoring. According to the SoapUI website, more than nine million developers use the software. A paid pro version is also available, which offers additional benefits. It also offers training and certification. 

    1. PostmanPostman is another popular choice. As we mentioned in the SOAP test, Postman is also open-source. You can use it for REST, SOAP, and GraphQL. The software offers automated testing, mocking, API monitoring, and more.

    1. Rest-AssuredRest-Assured is, as the name suggests, exclusively for use with REST APIs. Java and CSS are its top languages. It is open-source, and the website offers extensive documentation and guides.  

    1. API FortressAPI Fortress is a paid solution, and many consider it well worth the price. You can use it with REST, SOAP, GraphQL, Web Services, and Microservices. You can automate tests and monitor internal APIs. They offer a free trial for those who would like to check out their services ahead of time.

Benefits of Testing SOAP and REST Services

Testing is a fundamental aspect of software development that ensures the reliability and performance of applications. When it comes to web services technologies such as SOAP and REST, testing is particularly crucial. In the world of APIs, where seamless interaction between disparate systems is the norm, the need for rigorous testing becomes more pronounced. Below, we delve into the major benefits of testing SOAP and REST services.

Ensuring Consistency and Predictability

By thoroughly testing SOAP and REST services, developers can ensure that these services behave as expected under different scenarios. This consistency and predictability are key to providing a seamless experience to the users of the services. Whether it's a mobile app relying on a REST service to fetch data or an enterprise application using a SOAP service for a critical business operation, any unpredictability can lead to significant issues.

Improving Security

Web services are often exposed to the internet, making them potential targets for malicious attacks. Regular testing helps identify and patch up security vulnerabilities, protecting sensitive data from being exposed. For SOAP services, this could involve testing WS-Security implementations, while for REST services, it might mean ensuring proper authentication and authorization mechanisms are in place.

Enhancing Performance

Performance is a critical aspect of any web service. Users expect fast response times and minimal latency. Testing allows developers to identify and eliminate performance bottlenecks, thereby ensuring that the SOAP or REST service can handle heavy loads and high traffic.

Facilitating Interoperability

Both SOAP and REST are designed to promote interoperability across diverse systems. However, due to the differences in platforms, programming languages, and system architectures, issues can arise. Testing these services in different environments and configurations helps ensure they remain interoperable and can effectively communicate with other systems.

Enabling Better Error Handling

Proper testing also ensures that both SOAP and REST services can handle errors effectively. Whether it's a client error (like sending invalid data) or a server error (like a service being temporarily unavailable), the service should be able to handle the error and send back a suitable response. This is especially important in SOAP services, where the protocol's built-in error handling needs to function correctly to maintain smooth operation.

Increasing User Satisfaction

All these benefits contribute to increased user satisfaction. Whether the 'users' are end-users interacting with an application or other systems interfacing with the web services, a well-tested, reliable, and high-performing SOAP or REST service can significantly enhance the user experience.

In conclusion, investing time and resources in testing SOAP and REST services is essential for any organization aiming to deliver high-quality, reliable, and secure web services. It aids in building a resilient system that not only meets current requirements but also is adaptable for future needs.

The question of SOAP vs. REST does not have a definitive answer. Both have their place, along with some advantages and disadvantages--depending on your needs. Choosing which is right for you really depends on your environment, how you need to deploy APIs, and the programming languages you will be working in. An analysis of the pros and cons of both protocols would be prudent before you decide on either SOAP or REST. It's quite likely you'll find a need for both.   Whichever protocol you pick, make sure you test your APIs regularly. Catching errors or security issues in a test environment before they make it into production can save you from disaster later on. 

Manage and Test APIs with DreamFactory

If the process of testing a SOAP service or REST web service looks pretty complex for you, you are not alone. Many companies outsource their API testing to an API management platform like DreamFactory. We provide Restful services to help you build IoT, mobile, and web applications. We also help you monitor and test APIs using little or no code. DreamFactory is available in the cloud or on-premise. We offer such powerful security options as Active Directory, OAuth2, Okta, and more.  

If you are seeking a solution to generate customizable REST APIs and build secure SOAP services automatically, contact DreamFactory today and receive a free trial.

Frequently Asked Questions: How Do You Test a SOAP and REST Service?

What are SOAP and REST services?

SOAP (Simple Object Access Protocol) and REST (Representational State Transfer) are two different web service communication protocols. SOAP is a protocol which was designed before REST and came into the picture. The main idea behind designing SOAP was to ensure that programs built on different platforms and programming languages could exchange data in an easy manner. REST, on the other hand, is a new approach to develop services over the web and not a protocol like SOAP.

What tools can I use to test SOAP and REST services?

There are several tools available to test SOAP and REST services. Some popular options include Postman, SoapUI, REST Assured, and API Fortress. These tools provide features for sending requests, receiving responses, and automating testing processes.

How do I test a SOAP service?

To test a SOAP service, you need a tool like Postman. You'll enter the service's URL, include any necessary body data, set your request headers, and then send your request. The tool will provide a response that can help you troubleshoot any issues.

How do I test a REST service?

Similar to SOAP, testing a REST service involves entering the service's URL into a tool like SoapUI, sending a request, and reviewing the response. REST services can use a wider variety of methods, including GET, POST, PUT, and DELETE.

What's the difference between SOAP and REST?

The main difference between SOAP and REST is the way they handle communications. SOAP uses XML exclusively for its messaging format and requires more overhead due to its detailed messaging framework. REST, however, can use multiple formats like XML, JSON, etc., and is considered more lightweight and flexible as it leverages standard HTTP protocols.

Can I automate SOAP and REST testing?

Yes, using tools like Postman, SoapUI, REST Assured, you can automate the process of sending requests and checking responses. This can be particularly useful for regression testing, where you need to check if changes in the code have not affected existing functionality.

How important is it to test my SOAP and REST services?

Testing SOAP and REST services is crucial to ensure the functionality, reliability, performance, and security of your web services. Regular testing can help you catch and fix problems before they impact your users or compromise your systems.