How to use soapUI 5.0 to post JSON to REST Service

I wrote an article on the same topic but with version 4.5.1 soapUI back in 2013. To post JSON with an 4.5.1 version soapUI, you almost have to trick the application by explicitly typing in the media type ‘application/json’, and there are also a few settings that don’t really make sense. I’ve always forgotten the steps and had to go back to check my blog post.

Since then I have tried a couple of newer versions of soapUI for the same task, hoping it got more intuitive, but eventually I stuck with the 4.5.1 version because I didn’t see much improvement in those versions. Today I get my hands on the latest 5.0 version of the tool. Still free, great!
First, I crate a new SOAP project. The ‘Opens dialog to create REST Service’ option is gone. OK. It is already simpler from the first step.
1

Now my project is created, I right click the project and select New REST Service from URI.

2

In the popup window, I put in the service endpoint where I am going to post my JSON to.

3

BOOM! It creates everything for me. No need to provide a Service Name, Parameter Name, or Method Name, everything is extracted from the endpoint provided. This is a great UI design because if out of nowhere it asks the user to provide a Service Name, she will be confused – What is the Service Name for?

4

It also automatically opens up Request1 where you can see it by default selects GET method.

5

I changed the Method to POST. It selects the correct Media Type for JSON posting. Just type in your JSON body and click the green arrow on the left top corner to post.

6

I am impressed by how easy the process becomes and glad that the development team is putting efforts on improving user experience, even though it is already a well-functional application. User experience is really a big part of software. A good UX can really change your life!

Post JSON to REST web service with soapUI

Among several web service test tools I have used, including WCFStorm, VS WCF Test Client, and other proprietary test tools, soapUI is my favorite. In a recent project, with the help of soapUI, I was able to add custom fields into HTTP header, compose the authentication header field, and POST JSON data to a REST web service. This post aims to provide a quick guide on how to add REST web services to soapUI and post JSON to the services.

Create a new project.

9-17-2013 11-00-15 AM

Provide a name and select the option Opens dialog to create REST service. Click OK.

9-17-2013 11-01-25 AM

In the next screen, provide the web service’s URL and select the option Extract Resource and Method from specified Endpoint, so that SoapUI can analyze the URL and find out the parameters in it. In my example, Site ID and User ID. Click OK.

9-17-2013 11-03-17 AM

You can define the parameter names and default values on the next screen. Click OK.

9-17-2013 11-07-07 AM

Next you can setup your method, including HTTP method and parameters. We will select POST here to demonstrate how to post JSON.

Click OK to finish creating the method.

9-17-2013 11-08-49 AM

Now we can go ahead to expend our project and method, and select the request just created. On the right pane, our parameters and end point are displayed.

9-17-2013 11-10-19 AM

Next, modify the Media Type to using application/json. There is no such an option in the dropdown list so it has to be typed.

Then type up the JSON you want to post.

Click on the green arrow on the left upper corner of the request. soapUI will post the data to the endpoint.

9-17-2013 11-16-16 AM

Click on the Raw tab to view the raw data just posted!

9-17-2013 11-19-27 AM

As it is demonstrated, soapUI is a very flexible and effective tool which offers a free, quick, and simple solution to test web services.