A pattern for easily handling web services in your Android application
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This project demonstrates a pattern for easily handling webservices in your Android applications.

Communicating with a back end web service can be split up into 3 parts.

1. Base Web Service 

Implementing a Base Web Service Class which handles GET, POST and multi-part upload requests. This class directly communicates with the Apache HTTP Client and processes response messages, network errors, server side errors.   

2. An API Class for each request

The next layer of the web service stack which handles responses from the Base Web Service class and processes the input according to application logic. Ideally rest of the application classes communicate with this class. 

3. Model classes for each request and response bean

The parameters of a request and response can be bundled in the form of POJOs. These classes are essentially beans which will contain suitable getters and setters. 

Putting it all together

For sending an API request, a the required parameter values and sent to the API Class for that request by the caller class. The API class will process the input parameter and build the appropriate request bean. The API class then forwards the request to the Base Web service class along with the response class signature that is expected back. Upon receiving the response, The API class does any post processing logic on the response bean and forwards it to the caller class.


This code is licensed under BSD License. The text of the license is available in the LICENSE file.