I have been reading about about Restful webservices being Stateless. I can also see that most of Soap based webservices are also stateless and can be made stateful if needed and making them stateful will depend on implementation. So if a soap based webservice is stateful then a session id will passed with every request, to continue with session.
我一直在阅读有关Restful webservices无状态的信息。我还可以看到,大多数基于Soap的Web服务也是无状态的,如果需要可以使其成为有状态并使它们成为有状态将取决于实现。因此,如果基于SOAP的webservice是有状态的,那么每次请求都会传递会话ID,以继续进行会话。
My query is why can't same be done with Restful webservices, I think i should be able implement a webservice which can continue with same session where session id is passed by Restful webservice making is Stateful.
我的问题是为什么不能用Restful webservices做同样的事情,我认为我应该能够实现一个webservice,它可以继续使用相同的会话,其中会话id通过Restful webservice制作是有状态的。
So my question is, Are RestFul webservices just a concept with a guideline not to make them stateful? or there will be checks in Restful webservice libraries [like Jersey ] to stop people from doing so?
所以我的问题是,RestFul webservices是一个概念,其指导原则是不使它们成为有状态的吗?或者会在Restful webservice库(如泽西岛)中检查以阻止人们这样做?
2 个解决方案
#1
11
The statelessness of REST is designed to ensure applications scale well. You can add state, but it's at a trade-off in scalability.
REST的无状态性旨在确保应用程序可以很好地扩展。您可以添加状态,但在可伸缩性方面需要权衡。
One of the most common reasons to add state to REST is for authentication. Once a secure connection is established, a secure cookie can be sent to the client. This cookie is then added by the client to all requests for the session. The server maintains state and then loads that state in with every request based on the cookie.
向REST添加状态的最常见原因之一是进行身份验证。建立安全连接后,可以将安全cookie发送给客户端。然后,客户端将此cookie添加到会话的所有请求中。服务器维护状态,然后根据cookie为每个请求加载该状态。
Consider a simple web page. If you are not maintaining state, you can put up a reverse proxy, cache the page in memory by URL, and distribute that resource across many servers for load. If you now add the name of the currently logged in user to that web page, you can no longer cache anything (at least at the most basic HTTP level). The response can now be cached only with a combination of the authentication cookie and the URL.
考虑一个简单的网页。如果您不维护状态,则可以建立反向代理,通过URL将页面缓存在内存中,并将该资源分布到许多服务器上以进行加载。如果现在将当前登录用户的名称添加到该网页,则无法再缓存任何内容(至少在最基本的HTTP级别)。现在只能通过身份验证cookie和URL的组合来缓存响应。
#2
1
As long as I know, we(.net developers) can use WS-binding in wcf for stateful Web services.
只要我知道,我们(.net开发人员)可以在wcf中使用WS-binding来建立有状态的Web服务。
#1
11
The statelessness of REST is designed to ensure applications scale well. You can add state, but it's at a trade-off in scalability.
REST的无状态性旨在确保应用程序可以很好地扩展。您可以添加状态,但在可伸缩性方面需要权衡。
One of the most common reasons to add state to REST is for authentication. Once a secure connection is established, a secure cookie can be sent to the client. This cookie is then added by the client to all requests for the session. The server maintains state and then loads that state in with every request based on the cookie.
向REST添加状态的最常见原因之一是进行身份验证。建立安全连接后,可以将安全cookie发送给客户端。然后,客户端将此cookie添加到会话的所有请求中。服务器维护状态,然后根据cookie为每个请求加载该状态。
Consider a simple web page. If you are not maintaining state, you can put up a reverse proxy, cache the page in memory by URL, and distribute that resource across many servers for load. If you now add the name of the currently logged in user to that web page, you can no longer cache anything (at least at the most basic HTTP level). The response can now be cached only with a combination of the authentication cookie and the URL.
考虑一个简单的网页。如果您不维护状态,则可以建立反向代理,通过URL将页面缓存在内存中,并将该资源分布到许多服务器上以进行加载。如果现在将当前登录用户的名称添加到该网页,则无法再缓存任何内容(至少在最基本的HTTP级别)。现在只能通过身份验证cookie和URL的组合来缓存响应。
#2
1
As long as I know, we(.net developers) can use WS-binding in wcf for stateful Web services.
只要我知道,我们(.net开发人员)可以在wcf中使用WS-binding来建立有状态的Web服务。