How to access IBM MobileFirst 7.1 default attribut

2019-09-14 15:48发布

I am working on migrating a IBM MobileFirst 6.3 project to version 7.1 and enabling the 7.1 session independent mode. I have specified the attribute store as the worklight default runtime database.

In the previous version I have used HTTPSession object in HTTP JavaScript adapters to dynamically store some minimal data related to the current user session as shown in the sample code below.

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

As I cannot use session object anymore, are there any WL.Server APIs available for explicitly store/retrieve/remove data from the default attribute store (WL run-time database)? Couldn't find any examples on this. Please advise. Thanks.

1条回答
时光不老,我们不散
2楼-- · 2019-09-14 16:10

Knowledge center documents this scenario and solution for 7.1 Session Independent mode here

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

Saving applicative state between requests in Java RESTful adapters

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®

Sample also is attached in the link above.

查看更多
登录 后发表回答