What does view state in REST mean?

I read all over the network to get the exact meaning of two words:

REPRESENTATIVE CONDITION

I have doubts. I misunderstand these conditions. I want to clarify understanding with someone how good this is.

I understand that there is a resource located on the server. SO Rest means that the transfer of some representative state of this resource to the client.

If the server has resource x, then if we can make the representative state y of resource x and transmit it over the network, then what REST means is correct or what is the correct value for this. can someone explain this to me.

+51
soap rest web-services
May 02 '12 at 16:43
source share
7 answers

Representative state translation refers to the transfer of "representation". You use the "view" of the resource to translate the state of the resource that lives on the server into the state of the application on the client.

+44
May 02 '12 at 20:55
source share

Although REST is stateless, it has a state transfer in its name. This is a bit confusing to everyone.

Stateless

When you open a web page in a browser, you will act as a service consumer, and the www server will act as a service provider to serve you through a web page. If this is a normal connection, the client and server will shake hands and initiate a session (called a TCP connection).

After that, based on the behavior of the server and client, the state will change to ESTABLISHED, IDLE, TIMEOUT, etc. But in REST, we use the HTTP protocol, which is stateless, that is, the server will not store any information about the client. The client is responsible for sending all the details required by the server for maintenance, which means when we call the URI http://somedomain:8080/senthil/services/page1 from the server, it has enough information that the client is fully servicing page1.

State transfer

Using the same example, when you open a web page using some URL to view the image file (RESOURCE) on the server, the www server will show you (the client) the image in some format, i.e. RESOURCE REPRESENTATION (image file).

During this process, the constant state of the server resource (i.e. the state of the image file that is stored in the server database) will be presented to the client in an understandable format, i.e. client application state . Thus, the state of the resource will remain constant in relation to customers, and only the presentation of the resource will change, which, in turn, will change the state of the application.

Finally, the representation of the resource (how the image is displayed to the client), which implicitly changes the state of both the server and the client, is called REST.

+51
Feb 19 '14 at 8:13
source share

Each object has a certain state (data) and behavior (methods). In order to transfer the state of an object on the server to a client at a particular moment in time, some kind of representation is necessary, for example, JSON or xml or any other format.

Thus, REST is designed to create a representation of the current state of an object and transmit this view over the network.

+21
Feb 01 '18 at 9:04 on
source share

I think that the whole question about the concern of the REST architectural style comes down to the understanding that the author, Roy Fielding, had in mind to propose in his dissertation a set of architectural principles for constructing architectures based on the hipertext or hipermedia paradigm.

This paradigm, I think, is the central key to understanding this important topic.

Behind the style of organization of client-server application architecture proposed by Roy Fielding, I think that there is a specific idea of ​​a modern client-server application, which consists of a kind of mechanism for managing the state of the application state, the state of which is potentially expandable to infinite.

In this vision, Ipertext \ Ipermedia is the center of the entire architectural style proposed by Fielding, and the key concept that allows this paradigm to work is "representative (state) transmission."

I think that "representative" refers to the concept of "transfer" , and not to the concept of "state", i.e. the transfer is representative (representative type), and this, in my opinion, is the main reason for the name "Transfer of state representation".

So, when creating a Restful application, an architecture based on web components is first created, each of which is combined with the other in a multi-level client-server architecture, sending each of them a view of its state.

Thus, the front-end, the first client of this architecture, goes through its states, displaying a representation of the states generated by the component or components that it invokes, supporting a single consistent interface, and not on the "private" api.

. This type of application, in the author’s mind, potentially expands to infinite states, since its states do not depend on a private api, but depend on a single-level system of identifiers (like URIs) by all agents in this architecture, several verbs to control the transition of their states and an agreed upon common representative transmission system or plus.

This transition ends with the presentation of its presentation to the server component being called through the verbs that make up the “public” api, which must belong to the stateless communication protocol used by the client component server.

Thus, this interaction of the client-server components consists in the exchange (transmission, transfer) of state representations of the components of the protocol using without saving the state.

And the basic concept that allows all of these architectures to potentially expand to infinity is a representative transmission that supports their architecture.

+2
Jun 06 '16 at 13:56 on
source share

The values ​​of the STATE TRANSLATION REPRESENTATIVE are REST

RESTful put DIRECT VERB in server

In the actual case study, the value entered in VERB usually has HTTP GET and POST

SIMPLE protocol is very similar to SOAP (has a lot of difficulties!)

If the answer is not satisfied, please provide a more detailed question.

REST has a lot of questions to discuss; this is the topic of many blogs and books.

+1
May 02 '12 at 16:59
source share

Imagine a status diagram - it will be done.

Simple LucidChart Status Chart

If it was a set of web pages, you start with the student’s Basic Program landing page. According to the diagram, when you click on the “Next” link, it will take you to the First-grader page - assume that the student has completed his studies. By clicking "next" several times, you get to the last page.

Of course, there may be other transitions, such as "Home", which allows you to go to the default page.

The visible state of the website has nothing to do with how the server implements this connection internally - these are internal states. It can be several databases, servers, and what not. A student may end and his / her status may be updated using other methods. The client is not aware of these details - but can always expect to get a consistent visible state (set) for consumption by a person (or machine).

Another example. When you look at this page, you are in a specific identifiable and reproducible “location” in the StackOverFlow web hierarchy.

So, RESTful State deals with navigation.

+1
Nov 21 '16 at 18:46
source share

TL; DR

Representational state transfer or simply REST is a term for exchanging data in well-defined formats in order to increase interoperability. Through the application of certain restrictions, a decoupling between clients and servers must be achieved, which makes the former more stable, and the latter more flexible for changes.

A resource representation is the result of applying a mapping from the current state of the resources to a well-defined syntax and structure of multimedia types. Therefore, it is closely related to content matching , which defines the process of media type matching to transform the state of resources into the requested view (= syntax and structure).




REST can be considered as a method that allows you to separate clients from servers / APIs in a distributed system, which gives server freedom the opportunity to develop and change its structure in accordance with its needs, without violating the implementation of the client.

To get such a strong benefit, you need to create a couple of preconditions, since almost nothing comes for free. Here, Fielding identified a couple of limitations that he further clarified (and explained) in his well-known blog post . Servers cannot achieve such freedom if clients do not follow the REST approach, and clients cannot dynamically explore further possibilities if the server does not support clients in such situations. In short, both sides must follow the same principles. If this approach is not followed, the direct connection between the server and clients will remain, which will lead to failures if the server ever changes.

But how is separation really achieved?

First, the server must support the client in carrying out its tasks, including URIs that clients can use. The presence on the server of all URIs that the client can call from the current state in which the client is located eliminates the need for the client to know the API and the structure of the URI in advance.

Second, instead of allowing clients to interpret URIs, servers should return URIs in conjunction with link relationship names. Those. instead of a client using (and interpreting) a URI like http://server.org/api/orders , it should use a link relation like new-order . If the server changes the above URI to something like http://server.org/api/new-orders for any reason, clients using link relationship names will still be able to perform their task, while for those who using the URI directly, an update is required before they can continue.

To my knowledge, there are still no standards in which such link names should be defined and documented. For collection links, the semantics of relationship names, such as self , prev , next , first and last , seem quite significant, although something more specific to the subject area, such as order or product-xyz , may not matter. Such semantics can be described either in special types of media, or in new standards.

So far, these points are about the HATEOAS limitation, but unfortunately that's not all. According to a Fieldings blog post:

The REST API should spend almost all of its descriptive efforts on defining the types of media used to represent resources and managing the state of the application, or on defining extended relationship and / or hypertext markup names for existing standard media types.

Field further comment that:

The REST API should never have "typed" resources significant to the client. Specification authors can use resource types to describe the server implementation behind the interface, but these types must be irrelevant and invisible to the client. The only types that are relevant to the client are the current media type representations and standardized relationship names.

A typed resource is a resource in which the client has an assumption of content. That is, the client who received the http://server.org/api/user/sam+sample URI with the link relationship name user determines that the data belonging to this resource describes the person and therefore may try to streamline the presentation of the application/json data resource in the Person object.

The problem with typed resources is that clients have certain pre-assigned assumptions or knowledge regarding the data contained in such resources, that is, a user resource that can vary from server to server. While one server can provide a username as a name property, another server can use firstName and lastName , and the client that wants the server practically does not support every possibility. In addition, if the server ever changes its logic, clients may break with a certain probability. To counteract this type of communication, media types should be used.

Media types, which are a human-readable textual description of the presentation format, determine the syntax used, as well as the structure and semantics of the available elements contained in documents exchanged in this format. Therefore, applications conforming to the REST architectur model should use installed or custom media types to increase compatibility. Instead of directly connecting the client and server, both are actually associated with media types. Support for these types of media can be provided either by loading existing libraries, or by implementing the specification from scratch. Even loading these types of media dynamically through plugins is possible, if supported.

Clients and servers should use content negotiation to negotiate a common multimedia format that both parties understand, to share the current state of the resource. Content negotiation is achieved by providing an HTTP Accept header (and / or one of its native elements) that lists the MIME types that the client can or wants to process within the request and the server responding to one of the requested formats, including the HTTP Content-Type response header Content-Type to inform the client about which media type representation was actually used, or to return a 406 failure response.

For the user example above, clients can send an Accept HTTP header with the following contents: application/vcard+json, application/hal+json;q=0.6, application/json;q=0.1 server, which asks the server to return the state of the resource in the syntax and structure defined by one of the listed media. types. In addition, it indicates that the client prefers to receive a state formatted in accordance with the specification for the media type description application/vcard+json , and if the server cannot do this, it should prefer hal + json over the traditional json syntax. The server now either displays the current state of the resource in one of the requested formats, or responds with a corresponding 406 error message if either all the requested media types are unknown, or the state cannot be converted to such a structure or the default presentation is supported by the client.

Summarizing, we can say that REST is a method used to achieve high interoperability, relying on clearly defined types of multimedia and for branching clients from servers using features such as content negotiation and HATEOAS. As a reward, customers will be resistant to changes and, therefore, need less maintenance in general, while the server gets the opportunity to evolve and change without fear that customers will not be able to interact with it as soon as the changes take effect.

Certain things, such as standardized meaningful names for link relationships, custom domain-specific media types, and mapping processes to convert state to applicable representations of media types, should be set up first, which is a non-trivial task of TBH, although, while available, they provide the above advantages.

+1
May 31 '18 at 13:20
source share



All Articles