Automation Testing

soapUI – How to Test a REST Service

By Test Guild
  • Share:
Join the Guild for FREE

What is REST? Why is it Needed

REST (Representational State of Transfer) is a lightweight option for developing web services the uses the HTTP protocol –a fact that makes is simpler with less overhead than a web service that uses the SOAP protocol.

Today we'll be looking at soapUI but you can also programmatically test a rest service using a library like rest-assured without using a vendor tool.

(If you're interested in learning how to use soapUI to test SOAP web services, check out my post/video: soapUI – How to test a web service.)


Twitter API

For this example, I'll be using the Twitter API (GET statuses/user_timeline Resource) to perform a search for and return the last five tweets on my Twitter timeline:

https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=jcolantonio&count=5

How to use soapUI to test REST service

Here are the steps to follow to get started using the free version of soapUI with REST testing:

    1. Create a new project in soapUI named TWITTER REST (make sure you select the Opens dialog to create REST Service); click “OK”


    1. In the New REST Service dialog, enter the Service Endpoint:
      https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=jcolantonio&count=5
    2. Click on the “Extract Resource/Method” and click “OK”


    1. On the New REST Resource dialog, click on the “Extract Params” button. You should have two parameters named id and count. Click “OK”


    1. In the New REST Method dialog, enter the Method Name, “GET JOE TIMELINE” and click “OK”


    1. Click on the “GET JOE TIMELINE” Request 1 and click on the green run arrow


  1. Cool! You should be able to see the XML results returned from the Twitter service:


Now let's add assertions to validate the response

In order to verify that the correct response has been returned, you'll need to add an assertion. For this example our assertion is going to verify that five twitter entries were indeed returned by response of the service.

    1. First, click on the request's “Add this REST request to a testcase” icon.


    1. Name the testsuite “TWITTER REST,” and the TestCase “GET TIMELINE.”
    2. Add the Request to TestCase. Accept all the default values and click “OK.”


    1. You should now have a TWITTER REST testsuite under your soapUI project:


Click on “GET JOE TIMELINE” Request and click “Assertions” then click on the “Add an assertion” icon.


    1. In the “Add Assertion” screen, click on Property
      Content>XPath Match and click the “Add” button.


    1. For the XPath Expression, enter:
declare namespace ns1='http://www.w3.org/2005/Atom';
count(//ns1:feed/ns1:entry)

 

    1. Expected Result: enter “5.”


  1. Click the “Save” button and re-run.
  2. Your “assertion” should be green.


How to Test a REST service and Rest Easy

That's it! You can now rest easy in the knowledge that you now know how to test a REST service using soapUI!

Optimized Bio with Podcast Longevityfor

Maximum Credibility & SEO

A bearded man with blue glasses and a black-and-white jacket smiles at a microphone in a studio setting.

About Joe Colantonio

Joe Colantonio is the founder of TestGuild, an industry-leading platform for automation testing and software testing tools. With over 25 years of hands-on experience, he has worked with top enterprise companies, helped develop early test automation tools and frameworks, and runs the largest online automation testing conference, Automation Guild.

Joe is also the author of Automation Awesomeness: 260 Actionable Affirmations To Improve Your QA & Automation Testing Skills and the host of the TestGuild podcast, which he has released weekly since 2014, making it the longest-running podcast dedicated to automation testing. Over the years, he has interviewed top thought leaders in DevOps, AI-driven test automation, and software quality, shaping the conversation in the industry.

With a reach of over 400,000 across his YouTube channel, LinkedIn, email list, and other social channels, Joe’s insights impact thousands of testers and engineers worldwide.

He has worked with some of the top companies in software testing and automation, including Tricentis, Keysight, Applitools, and BrowserStack, as sponsors and partners, helping them connect with the right audience in the automation testing space.

Follow him on LinkedIn or check out more at TestGuild.com.

  1. Hi Joe,

    can you please suggest how to automate gwt graphs(pie charts,bar charts, performance graph).
    I need to capture x-axis and Y axis values( i.e 2010-2011,2011-2012) in graphs.We are using QTP-10.00 and Application developed in Google Web Development ToolKit(GWT).

    Thanks in Advance.

    Regards
    Venkat gudi

  2. venkat » Hi Venkat – I’ve been trying against some Google graph samples without any luck. I have not tried creating my own sample to see if there is a method that can be exposed that will return X and Y info. You might want to check with your developers to see if this is an option.

  3. Hi Joe,

    Can you tell me, what I must change in the count(//ns1:feed/ns1:entry) because I dont have in the xml File.

    Thanks

  4. Hi,

    I am trying the same thing form the SoapUI but i am not able to get the response in SoapUI. Do we need to change some settings in the Soapui to connect to Internet like proxy setting..?? i am able to get the number of tweets in browser using SoapUI API but not from SoapUI. please help.

    thanks in advance

  5. What if if the response is like below? How do i need to test with xPath expression?Can you please guide me.
    <![CDATA[

    type=”text/javascript”>
    ]]>

  6. Hi Joe,

    Do you have sample video or steps for POST JSON request and assertions.

    I am now ok with GET but still not with POST. It would really help.

    Thanks,
    Jaymin.

  7. Hi Joe,
    I am new to web services testing and to soapUI tool. But then with the help of few online resource I see a good picture on “what is a webserivce , HOw to works, what is Get and Post request?”. And then I used soapui tool to try a REST service and i got output as what i needed. Now my query is, if soapui tool is making life easy to send GET or POST requests with just few data’s (such as url) and clicks then there is a possibilty to do same thing without using tool. If it is possible then can you give me some inputs on how to do it?Thank You krish

  8. Dear Joe,

    I am new to the testing of HTTP services. I have found the SOAP UI as a tool to automate my testing activities. Could you please help me with what I am trying to achieve.
    I have a set of XSD’s and XML messages and I need to fire the message over an http service, get the response back. I have around 52 messages, each having 300 more test cases. I need to automate all the cases and make a functional testing for an entire flow.

    Please help me in setting up a project with this and to achieve the result.

  9. Dear Joe,
    if I would like to test whole Twitter web service what endpoint should I choose?
    Best Regards,

  10. Not sure what you mean by the “whole” twitter web services. I think you would have to use a bunch of the twitter apis to create a scenario like that. I don’t think there is just on wdsl for all the twitter functionality.

  11. Hi Joe, is it possible to define our own response so that webservice return the same ?

    for example when you connect to rest webservice with request A then we know webservice will alway send respose B but I want response as per my requirement let say response C. is it possible ?

    Please can you reply to my email at kapil.jain@cgi.com

  12. Hello Joe,

    Do you have any video for load testing in soap ui? Also could you explain the parameter use in load testing like thread, delay, limit..etc.

    Thanks

  13. Hi Joe Colantonio,

    I am using SOAP UI PRO 4.6.3 version. Here i am unable to given REST service Name and also not editing. It is taking url name like(localhost).In File–> New REST Project —> url. example “http://localhost/CurrencyConvertor.asmx”. then it is taken service name as “localhost”. But here i need to give domain name.
    Can you please help me.

    Thanks,
    Ram.

  14. Hi Sagar – unfortunately I don’t have any videos for load testing using loadUI. I will add it to my list of possible future posts. thanks for the suggestion!

  15. Hi Joe,

    1) From where screen_name parameter should be taken?

    2) Is there any need to add authorization in SOAP UI?

  16. i have post the rest api request where i am getting the error in response HTTP Status 415 – Cannot consume content type…so my question is where i need to set the content type

    thanks in advance

    regards
    mahadev

  17. hi,
    i have 40+ rest so how to use all rest api in rest one by one without any human interface.can i use script in SOAPUI? if yes, so please give me a step how to use it

Comments are closed.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Solving the Top 6 Mobile Automation Challenges Fast (DevAssure Guide)

Posted on 02/27/2025

Are you tired of struggling with the mobile test automation setups? Does managing ...

Top Software Testing Conferences (2025 Guide)

Posted on 01/19/2025

Why a list of top software testing conferences? Many testers ask me what ...

Top 8 Automation Testing Trends Shaping 2025

Posted on 01/11/2025

As we enter 2025, here are some automation testing trends I think will ...

AG '25 Online Event: Defeat Flaky Tests, Future-Proof Your Skills, & Grow Your Network in 2025 - Learn More >>

⭐⭐⭐⭐⭐ “A must-attend virtual event for all testing professionals.” — George Ukkuru (Head of Quality Eng.)