How should I communicate with the DB? Technology Recommendations

4

I'm having an Android project, where I'm trying to do everything using free platform.

I need the field devices to communicate with the database, and I heard something about JSON and Web Service.

So I would like you to recommend me, "SHOW THE WAY", what tools should I use for my project, so I will study them later.

    
asked by anonymous 09.06.2014 / 17:51

1 answer

4

Development for mobile platforms is usually based on tools already available on other platforms (usually web). So, mobile solutions are nothing more than new interfaces for the same application, and because of that there are several pitfalls you may face, the biggest of which is unnecessary code repetition.

The problem

I need to make my application available on more than one platform, and I have to redraw access code to database and business rules, which hurts DRY (Do not Repeat Yourself) precept.

The solution

By using webservices, you can only develop the business logic of your application once, making all subsequent platforms only consume webservice methods, reducing your localized application to interface development and using% (such as access to the device's camera, for example).

Using webservices, you will have methods that allow you to use the features of the application from any platform.

Webservice standards

Today we have two main standards for webservices: APIs and SOAP .

  • The REST architecture is based on the definition of the service from SOAP files, which provide a description of the methods available in the service. The methods are called by their names (for example, XML );
  • The LoginUsuario architecture is based on the use of HTTP verbs to describe the desired operations, namely:

    REST : recovers resources
    GET : creates new resources
    POST : fully refreshes resources
    PUT : partially updates resources
    PATCH : excludes resources < p>

    The use of resources in webservices DELETE is based specifically on the HTTP method used to invoke the resource along with the parameters. Following the example above, REST could be a LoginUsuario request under the REST architecture

How to implement

This totally depends on the architecture in which you are working. In GET , a webservice class .net has the following syntax:

public class UsuarioController : ApiController
{
    // Pode ser invocado com uma requisição GET com dois parâmetros
public string Get(string user, string key)
{
    // Operações
}
}

Since you're working with Android, I'll assume you work with REST . Since I'm not familiar with this language, here are some links that can help you:

Webservice SOAP in Java
Webservice REST in Java

    
09.06.2014 / 21:25