Database Reference
In-Depth Information
Client/Server Frameworks
The Google Cloud Endpoints framework is only one of many
frameworks suitable for production client/server communication.
Following are a few other libraries that you may want to consider if you
are looking for a solution for client/server communication.
• GSON: Automatic Java object to JSON conversion
( https://code.google.com/p/google-gson/ )
• Volley: Framework for asynchronous HTTP requests
( https://developers.google.com/events/io/sessions/
325304728 )
• Retrofit: Java annotation-based framework for generating REST
API bindings ( http://square.github.io/retrofit/ )
The protocol the application uses is based on passing JSON encoded data in
HTTP POST requests and responses. For each message to be sent, the client
initiates a separate POST request with the data encoded in the body of the
request, and the server responds with a JSON object. If no errors occur the
client can go ahead and use the response object from the server. Because
this is a monitoring application, the server never has to return data to the
client, so when a request succeeds, the client simply receives an empty JSON
object. The client has to deal with three types of errors:
• Errors at the HTTP transport layer and below
• Request encoding errors
• Application level errors
You cannot control how the first class of errors is reported but the latter two
classes of errors are detected by the code, so you can decide how to signal
the issue. We chose to report request-encoding errors using the appropriate
HTTP client error (4xx) status codes. When the request is well formed but
the server encounters an error while processing it, we chose to return HTTP
status code 200 (which indicates success at the HTTP layer) but return a
JSON object containing the keys error and message to indicate why the
request failed. Finally, the client specifies the action to be performed with
the request object using the appropriate URL on the server ( /command/
Search WWH ::




Custom Search