如何在会话独立模式下访问 IBM MobileFirst 7.1 缺省属性存储



我正在努力将 IBM MobileFirst 6.3 项目迁移到版本 7.1 并启用 7.1 会话独立模式。我已将属性存储指定为 worklight 默认运行时数据库。

在以前的版本中,我在 HTTP JavaScript 适配器中使用了 HTTPSession 对象来动态存储一些与当前用户会话相关的最小数据,如下面的示例代码所示。

    var request = WL.Server.getClientRequest();
    var session = request.getSession();
    session.setAttribute("ID", "123");
    session.setAttribute("UserName", "xxx");

由于我不能再使用会话对象,因此是否有任何WL。服务器 API 可用于从默认属性存储(WL 运行时数据库(中显式存储/检索/删除数据?找不到任何关于此的例子。请指教。谢谢。

知识中心在此处记录了此场景和 7.1 会话独立模式的解决方案

https://www.ibm.com/support/knowledgecenter/en/SSHS8R_7.1.0/com.ibm.worklight.dev.doc/devref/c_java_server_side_api.html#java_server_side_api__java_rest

在 Java RESTful 适配器中保存请求之间的应用状态

In versions earlier than V7.1.0, developers were able to store the applicative state in the HTTP session, by using the session object, namely request.getSession() (see WL.Server).
If you are working in session-independent mode that became available starting with IBM MobileFirst Platform Foundation V7.1.0, the applicative state of the adapter must be persisted outside the session, for example, by using a database such as Cloudant®

示例也附在上面的链接中。

最新更新