Have fun. I hope it helps someone else get started.
It is kept as small and lightweight as possible but includes all the code to get a working authenticated service connection with a restful web services server. Think of it as the "hello world"/getting started How -to Java code to be re-used and extended to wrap around the full processing of any published REST web services.
I am writing an Android app to interact with many of my home Audio/Video devices and need to talk to my Universal-Devices ISY-994 home lighting controller using its REST Web Services. I could (and have) interact with the ISY-994 directly with its full and robust Java SDK but since I am including this in an Android app, I want to keep it as light as possible - without the inclusion of the UDI SDK Java libraries. Calling the REST interface is perfect for this.
I started with a proof-of-concept, to ensure I could communicate and consume Rest services, using the basic classes in the standard JDK.
I then extended it to focus specifically on my ISY-994, and its set of services (see UDI Wiki for the list of available services).
The source code for both the base generic class and the ISY994 extended class are included below.
Scope of this Rest Client
Extending this class to wrap around a specific Server and REST services
The generic class works out of the box on any configured Server URL, however it is easier to create a new class that extends the above base class with specific Rest service parameters, such as
Java Source Code
The source is released as free and open under the GNU license version 3.
My code depends (NOT Derivative) on a few Java files from the Apache Commons Codec library to perform Base64 encoding required by the http basic authentication. These files are licensed and re-distributed unmodified, as links below, under the Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0 .
If you plan on using this (or other REST client) within an Android app, you can use the Android Base64 class in the Android SDK that will handle the Encoding instead of the Apache Commons Codec library files. I commented out the import android.util.Base64 in the source. I tried it it works fine as well.
Base Java Class
ISY-994 Extension Java Class