1. The introduction… .
1.1, the REST Introduce…
1.1. Purpose …………………………………………………………………………… .
1.2, Writing principles… .
1.3, Change history… .
2. Service instructions
2.1 Services provided by the current system ………………………………………………………… .
2.2. Invoke the service ………………………………………………………………… in GET mode
2.3. Invoke the service ……………………………………………………………… by POST .
2, my collection service list…
2.1, the classification of the tag…
2.2, delete category labels…
2.3, update category labels…
1, the introduction
1.1 introduction to REST
REpresentational State Transfer (REST) is an architectural principle that treats Web services as resources that can be uniquely identified by their urls. A key feature of RESTful Web services is the explicit use of HTTP methods to represent the invocation of different operations.
Basic REST design principles use HTTP protocol methods for typical CRUD operations:
POST – Creates a resource
GET – Retrieves resources
PUT – Updates resources
DELETE – Deletes the resource
The main advantages of REST services are:
They are highly reusable across platforms (Java,.NET, PHP, etc.) because they all rely on the basic HTTP protocol.
They use basic XML instead of complex SOAP XML, which is very convenient to use.
Rest-based Web services are increasingly becoming the preferred approach for back-end enterprise service integration. Its programming model is simple compared to SOAP-based Web services, and the use of native XML (rather than SOAP) reduces the complexity of serialization and deserialization processes and eliminates the need for other third-party libraries that serve the same purpose.
1.2. Purpose of compilation
The purpose of this paper is to make the system functions modular and servitization, and provide users’ operations as services. In order to realize the integration between systems, the interaction between systems is transformed into customized service interaction according to service specification.
1.3. Compilation principles
Addressability Everything in REST is based on the concept of resources. Unlike objects or other nouns in OOP, a resource is an abstraction and must be addressable or accessible through a URI. Unlike SOAP or other standards, REST generates clothes, which are used to manipulate resources
Methods or verbs are not arbitrary. This means that developers of RESTful services can only use methods supported by HTTP, such as GET, PUT, POST, DELETE, and so on. So there is no need to use a service description language such as WSDL. To enhance scalability, the server side does not store state information of the client. This keeps the server from being tied to a particular client, making load balancing much easier. It also makes the server easier to monitor and more reliable.
The Representational client always interacts with some representation of a resource, never directly with the resource itself.
There can also be multiple representations of the same resource. In theory, any client holding a representation of a resource should have enough information to manipulate the underlying resource.
Any REST-based system should anticipate that clients need to access related resources and should include these resources in the returned representation of resources. For example, you can include related steps in the sequence of operations for a particular RESTful service in the form of hyperlinks, allowing clients to access them as needed.
1.4. Change history
2. Service instructions
2.1 Services provided by the current system
2.2. Invoke the service in GET mode
Description:
- The request methods include: GET (The area service is used as an example, and GET corresponds to each service Resource
@RequestMapping(value = “treeData”, method = RequestMethod.GET))
- Request URL: Rest service request address, which corresponds to value in the MAPPING configuration of XXXServiceResource. Java
@RequestMapping(value = “treeData”, method = RequestMethod.GET))
- The GET request contains only the request method and URL, and the returned result is returned to the client in JSON format
2.3. Call the service in POST, DELETE, and UPDATE mode
Description:
-
The request mode can be POST, DELETE, or UPDATE(take the save favorites function as an example (PUT request). @requestMapping (value = “save”, method = requestmethod.put) for each server Resource
-
Json parameters: POST, DELETE, and UPDATE may pass the parameters through Json, or directly join the parameters through the path. Here, we take transferring Json to the server as an example, corresponding to the server code:
public JSONObject save(@RequestBody JSONObject obj, BookmarkTag bookmarkTag) {
-
The request URL: Rest service request address: value@RequestMapping(value = “save”, method = requestMethod.put) in the mapping configuration of XXXServiceResource.
-
The result is returned to the client in JSON format
3. Service list (take my collection service as an example)
3.1. Add label classification
3.2. Delete category labels
3.3. Update classification labels
3.4. Obtain the list of classification labels