background preloader

API Testing

Facebook Twitter

How to build datatable using jQuery from REST xml response. How to append REST call JSON response to jQuery datatables. A RESTful Web service, an example. It's often hard for people to "get" REST, this is mostly due to the fact that REST isn't a tangible thing like a piece of software or even a specification, it's a selection of ideals, of best practices distilled from the HTTP specs.

A RESTful Web service, an example

I've always found that the best way to understand something is to see an example, to see the principles in action first and worry about the details later once I understand the general gist. So here's a little example of a RESTful version of a simple Web service you might already know about, the Delicious API. Delicious has “a simple REST API”, or rather, a simple POX over HTTP API, that is, it has a perfectly usable HTTP and XML based API for accessing your bookmarks and tags, but it isn't very RESTful.

Why not? First class objects aren't exposed as resources, so we can't access our bookmarks or tags directly. So (ignoring why) how can we make it better, make it more RESTful? It allows us to: What is REST? As REST is an acronym for REpresentational State Transfer, statelessness is key.

What is REST?

Essentially, what this means is that the necessary state to handle the request is contained within the request itself, whether as part of the URI, query-string parameters, body, or headers. The URI uniquely identifies the resource and the body contains the state (or state change) of that resource. Then after the server does it's processing, the appropriate state, or the piece(s) of state that matter, are communicated back to the client via headers, status and response body. Most of us who have been in the industry for a while are accustomed to programming within a container which provides us with the concept of “session” which maintains state across multiple HTTP requests.

In REST, the client must include all information for the server to fulfill the request, resending state as necessary if that state must span multiple requests. RESTful Web services: The basics. The basics REST defines a set of architectural principles by which you can design Web services that focus on a system's resources, including how resource states are addressed and transferred over HTTP by a wide range of clients written in different languages.

RESTful Web services: The basics

If measured by the number of Web services that use it, REST has emerged in the last few years alone as a predominant Web service design model. In fact, REST has had such a large impact on the Web that it has mostly displaced SOAP- and WSDL-based interface design because it's a considerably simpler style to use. REST didn't attract this much attention when it was first introduced in 2000 by Roy Fielding at the University of California, Irvine, in his academic dissertation, "Architectural Styles and the Design of Network-based Software Architectures," which analyzes a set of software architecture principles that use the Web as a platform for distributed computing (see Resources for a link to this dissertation).

Back to top Listing 1. Learn REST: A Tutorial. Getting Started with REST Testing. NOTE: As of version 4.6 of SoapUI, the functionality described in this article has been revised and improved.

Getting Started with REST Testing

If you're using an earlier version, please upgrade! SoapUI supports extensive testing of REST services and their resources, representations, etc. Let's start with a quick demo using the Google Maps API to get you started! Also, please try out a free 14-day trial of SoapUI Pro to tag along in the tutorial. While REST-testing isn't a Pro-specific feature, all tutorials on SoapUI.org are done using SoapUI Pro, so you'll have a better understanding of the feature if you do.

The way to create REST testing requests has been greatly simplified in SoapUI 4.6 – fewer steps are needed. Start by creating a new REST project from the File menu by choosing the "New REST Project" option in the File menu: Specify the following Google Map API URL in the Service Endpoint Field: REST Sample Project. Step1: Open MockService 1.

REST Sample Project

Double click on MockService. (see figure 16a - start MockService) 2. Click to start the mockservice. You will see mockservice "running on port 8080". ( see figure 16b - running on port 8080 ) RestFul Web Services. EdgeCast_Web_Services_REST_API_0-1.pdf (application/pdf Object) Difference Between API and Web Service. API vs Web Service API and Web service serve as a means of communication.

Difference Between API and Web Service

The only difference is that a Web service facilitates interaction between two machines over a network. An API acts as an interface between two different applications so that they can communicate with each other. An API is a method by which the third-party vendors can write programs that interface easily with other programs. A Web service is designed to have an interface that is depicted in a machine-processable format usually specified in Web Service Description Language (WSDL).

An API exactly defines the methods for one software program to interact with the other. In case of Web applications, the API used is web based. A Web service is merely an API wrapped in HTTP. The APIs can be exposed in a number of ways which include: COM objects, DLL and .H files in C/C++ programming language, JAR files or RMI in Java, XML over HTTP, JSON over HTTP, etc. Summary: 1. 2. 3. 4. A network for its operation. 5.