History
In early while working on a series of integration projects, we were using RESTful Web Services. To test our WebServices, I had started the project WizTools.org RESTClient (rest-client googlecode.com). RESTful WebServices itself was born out of disillusionment with its more complex predecessor, the WS-" stack. The bigger technology companies, sitting in their ivory towers had designed the backbone ofr;OA (Service Oriented Architecture) using a series of specifications collectively called the WS-* stack. These include: SOAP, WSDL, UDDI, WS-Security and WS-Policy, among others. The hacker community, dissatisfied with the introduced complexity ofWS-* stack, named a new architecture based on HTTP: RESTful WebServices. The word RESTful Web Services was coined by Roy Fielding in his PhD thesis, "Architectural Styles and the Design of Network-based Software Architectures" .
RESTful WebServices did not aim at protocol independence. It leverages some lesser-mown features of the HTTP protocol. For example, using normal Web browsers, we can make HTTP GET and POST requests. In addition to the common GET and POST, RESTful WebServices use the following:
•PUT
•DELETE
Note
The HTTP specification also defines other lL, request types like HEAD, OPTIONS and TRACE.
We did not find decent clients to test these types ofHTTP requests. REST Client was born.
Usage
RESTClient requires Java 6. To run the program, use the following command:
Features
The initial idea behind RESTClient was to acquire the capability to make different kinds ofHTTP requests, including GET, POST, PUT and DELETE. The latest version of RESTClient also supports other features like SSL, support for adding custom HTTP headers and body, HTTP 3ASIC and DIGEST authentication.
One prominent feature of REST Client is the ability to save requests, responses and the response body.1his is often required for regression testing and proof-of-failure. These options are available inside the File menu. The related file extensions are:
1rcq- The request format. 1his is a RESTClient-specific XML format storing the request details.
2rcs- The response format. 1his also is an XML.
3rcr-This is the archive of both request and response XMLs compressed as a zip file.
Jetty Servlet Container is embedded inside RESTClient. A servlet that verbosely prints out the request details is attached to it. To start the server, use the Tools menu. The default listening port of this server is 10 10 1. 1his can be changed during RESTClient start-up using the system property rc: trace-server -port.
The most powerful feature of REST Client is its integrated support for tests. RESTClient has the Groovy programming language embedded (Figure 2). So test classes can be written in Groovy. Test classes are based on Unit 3.x and tests are attached to each request.
As you can observe, the test classes need to extend. RESTTestCase internally extends junit.framework. TestCase. The instance of RESTTestCase has two predefined instance variables available: request and response. These instances have various convenient methods to access the request and response details.
request is of type org.
The command line
From version 2.3, RESTClient has two binaries: one GUI and one command-line. The command-line tool is used for running requests in a batch and logging their test results.
Extending RESTClient
During the development of version 2.3, the code was re-factored to a more modular form for extensibility. Now the code is organised into various modules managed by Maven. The restclient-lib module has the core functionality of RESTClient. Having this as the dependency, various interfaces have been developed (the RESTClient GUI, CLl and Ant plug-in being examples). To demonstrate the ease of the API, I will show you how to write the code to execute a request and write the response-body in the console. First add the dependency for restclient-lib in your Maven project for a detailed discussion on setting up the environment, refer to the Cook Book.




Reply With Quote
Bookmarks