session management in web services?

穿精又带淫゛_ 提交于 2019-12-12 09:42:32

问题


is it possible to manage sessions in web-services? if yes, how to manage session in it? is it similar to sessions we maintain in JSP or PHP? where does the info about the session will be stored, Client or Server?


回答1:


Is it java or .net question?

In .net you can easily use session state on webservice hosting server by setting EnableSession parameter in WebMethod attribute, for example:

[WebMethod(EnableSession = true)]
public bool Login(string login, string password)
{
    // you can use session here so for example log in user
    if(login = "administrator" && password = "secret")
       Session["authorizedUser"] = login;
}



回答2:


It's possible to use the Session object in .NET inside of a webservice...however I'd say it is bad practice. Typically speaking a webservice isn't passed data this way and the data in the service doesn't persist between calls.




回答3:


Here is an article on WS-ReliableMessaging, which has session support, and is supported on both java and .net development.



来源:https://stackoverflow.com/questions/3458604/session-management-in-web-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!