MashZone NextGen 10.2 | Appendix | Legacy Presto components | MashZone NextGen Development and APIs | Map MashZone NextGen Attributes to Artifact Input Parameters | Define MashZone NextGen Session Attributes
 
Define MashZone NextGen Session Attributes
You define MashZone NextGen session attributes in the request that generates the response with the data to be saved. Session attributes allow you to save data from one request and use it in subsequent requests for the current session. It is useful for sensitive or personal information that should remain in the MashZone NextGen Server for security or privacy reasons.
You use the optional MashZone NextGen Header/Parameter x-p-sessionbinding to define session attributes. This header takes an object with attribute definition expressions. Each expression provides the name for a new session attribute and an XPath expression that identifies the node within the response that should be saved in this attribute for the current session.
The XPath expression can identify a node with a simple value, such as '@session.ssn':'/customer/SSN'.
They can also identify nodes sets, such as '@session.articles':'/rss/channel/item' or one node with complex content, such as '@session.firstArticle':'/rss/channel/item[1]'. See A Brief Introduction to XPath 2.0 for more information on XPath expressions.
Note: The @ symbol defines a session attribute. You refer to session parameters with $, just as you do with global or user parameters. See Define MashZone NextGen Session Attributes for this syntax.
This first session mapping example takes a query response and maps two nodes with simple content to two MashZone NextGen session attributes.
Defining Session Attributes with Simple Values
...
connection.request({
url: "/mashzone/edge/api/rest/CustomerQuery/getCustomer?id=mr321y98&x-presto-resultFormat=
json&x-p-sessionbinding={'@session.ssn':'/customer/SSN','@session.name':'customer/name'},
type: "get",
contentType: "application/x-www-form-urlencoded",
data: requestBody
},
{ onSuccess: function(response, responseHeaders) {
//handle response data
},
onFailure: function(e) {
//handle error message
}
});
A later request then maps these MashZone NextGen session attributes to mashable input parameters:
Mapping Session Attributes with Simple Values
...
connection.request({
url: "/mashzone/edge/api/rest/CustomerNotices/renewalNotice?x-presto-resultFormat=
json&custSSN=$session/ssn&custName=$session/name,
type: "get",
contentType: "application/x-www-form-urlencoded",
data: requestBody
},
{ onSuccess: function(response, responseHeaders) {
//handle response data
},
onFailure: function(e) {
//handle error message
}
});
The next session mapping example shows a mapping from an RSS feed. This defines a complex MashZone NextGen session attribute that contains feed data for the first article from this web feed.
Defining Session Attributes with Complex Content
...
connection.request({
url: "/mashzone/edge/api/rest/someRSSFeed/getData?x-presto-resultFormat=json&x-p-sessionbinding={'@session.firstArticle':'/rss/channel/item[1]'},
type: "get",
contentType: "application/x-www-form-urlencoded",
data: requestBody
},
{ onSuccess: function(response, responseHeaders) {
//handle response data
},
onFailure: function(e) {
//handle error message
}
});
A later request then maps data from nodes within this MashZone NextGen session attribute to input parameters:
Mapping Session Attributes with Complex Content
...
connection.request({
url: "/mashzone/edge/api/rest/myMayshup/Invoke?x-presto-resultFormat=json&article=$session/
firstArticle/item/title&link=$session/firstArticle/rss/channel/item/link,
type: "get",
contentType: "application/x-www-form-urlencoded",
data: requestBody
},
{ onSuccess: function(response, responseHeaders) {
//handle response data
},
onFailure: function(e) {
//handle error message
}
});

Copyright © 2013-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Innovation Release