How should I communicate with DB? Technology recommendations

Asked

Viewed 123 times

4

I’m with an Android project, in which I’m trying to do everything using free platform.

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

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

1 answer

4


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

The problem

I need to make my application available on more than one platform, and I have to rediscover database access code and business rules, which hurts the DRY precept (Don’t Repeat Yourself).

The solution

Through the use of webservices, you can develop only once the negotiating logic of your application, thus making all later platforms only consume the methods of the webservice, reducing your localized application to the development of the interface and the use of APIs specific (such as access to the device’s camera, for example).

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

Patterns of webservice

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

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

    GET: recovers resources
    POST: creates new resources
    PUT: fully updates features
    PATCH: partially updates resources
    DELETE: excludes resources

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

How to implement

This totally depends on the architecture you are working on. In .net, a class of webservice REST 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
}
}

As you are working with Android, I will assume you work with Java. As I am not familiar with such language, follow some links that can help you:

SOAP webservice in Java
REST webservice in Java

  • 1

    OK, friend I will study, I will use MYSQL+REST IN JAVA thanks

Browser other questions tagged

You are not signed in. Login or sign up in order to post.