how to use Httpsession in REST web service?
how to use HttpSession in Rest web service to save to login username? And how to pass session to another web service class or other cl开发者_如何学Cass?
thanks
REST services, by definition, are not supposed to have session state.
Create an 'authenticate' method which takes credentials and returns a 'token'. Then all other service methods should take this token as one of it's parameters and validate that it's good and not expired.
Check out OAuth as an industry standard protocol for doing this. There are a number of 3rd party libraries for both publishing and consuming OAuth services.
精彩评论