Android Miscellaneous Notes

Android application and traditional server application system integration [JSON, Web Service "XML", network request, Token, heartbeat]

View Layer - Android Client


Middle Tier - Struts 2 + Spring 4 + Hibernate 4

  • Controller layer - Web layer (Struts 2) or Servlet layer [Controller]
  • Business logic layer—Service layer, which encapsulates DAO objects
  • Data access object layer—DAO layer, responsible for interacting with Domain Object objects, encapsulating atomic operations of additions, deletions, and changes
  • Persistent object layer - Domain Object layer, through the entity/relationship mapping tool [Map], the relational database data is mapped into objects, and the database is operated in an object-oriented manner. Here, Hibernate is used as the O/R Mapping framework

Database service - storing data


To interact with the PC server on the Android mobile client, the following conditions need to be met: cross-platform, standard transmission data format, and convenient interaction.

In order to communicate with the server, it is nothing more than two protocols: HTTP and TCP. If you are learning Socket for TCP, if you are HTTP, familiarize yourself with the HTTP protocol and related Java APIs. The following methods are extended from these two protocols: webservices soap, SSH JSON, xmlrpc (wordpress for android)...

Socket is not recommended, HTTP RESTful is recommended. If data is transmitted to the server, it is generally transmitted through RESTful API. In this way, we must first have a preliminary understanding of the HTTP protocol, at least know what the difference between GET / POST is.

If there are no special requirements, it is relatively simple and general to use webservices to transmit XML files. If there are requirements for data size and transmission speed, json is more suitable.

[The difference between Socket and HTTP connection]

The HTTP connection uses the "request-response" method, which not only needs to establish a connection when requesting, but also requires the client to send a request to the server before the server can reply to data.

The socket can be monitored, so once the socket connection is established, the two communicating parties can start sending data content to each other until the connection between the two parties is disconnected. Keep client and server data real-time and synchronized.

xml rpc is an rpc mechanism that uses the http protocol as the transmission protocol, and uses xml text to transmit commands and data.

RPC is the abbreviation of Remote Procedure Call. Translated into Chinese, it is Remote Procedure Call. It is a technology that calls a procedure (method) on a remote machine on a local machine. This process is also known as "distributed computing". .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325768125&siteId=291194637