Implementing a RESTful client using Apache Jersey

When integrating with cloud providers that expose REST API, and invoking it from my Cloud Driver Java-based implementation, I found the Apache Jersey client open source library quite convenient for implementing a RESTful client. Jersey is based on JAX-RS Java community standard, and offers easy handling of various flavors of calls, cookie handling, policy governance, etc.

Here is an example for invoking a POST call, using a JSON to relay invocation parameters, and using a token-based authentication:

For the full source code:

Here is an example of invoking a GET call, using explicit parameter listing and a session-cookie-based authentication:

The parsing of the XML response is done using DOM.