Create and manage access to a JSDO instance
- Last Updated: September 14, 2022
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
The following code fragment demonstrates how to create and use a JSDOSession and a JSDO:
let session, customer;
// create a JSDOSession for a specified web application
// that requires BASIC authentication
try {
progress.data.getSession({
serviceURI: 'https://oemobiledemo.progress.com/OEMobileDemoServicesBasic/',
catalogURI: 'https://oemobiledemo.progress.com/OEMobileDemoServicesBasic/static/CustomerService.json',
authenticationModel: 'basic',
username: 'basicuser',
password: 'basicpassword'
})
.then((object) => {
// The object that getSession() returns contains three fields:
// object.JSDOSession, object.result, object.info
session = object.jsdosession;
customer = new progress.data.JSDO('Customer');
return customer.fill();
}, (object) => {
console.log('getSession() failed');
return false;
})
.then(function (object) {
// The object that fill() returns contains three fields:
// object.JSDO, object.success, object.info
// Do other JSDO related tasks here because fill() succeeded
console.log(object.success);
console.log(object.jsdo.hasData());
return session.invalidate();
})
.then(function(object) {
console.log("Session is invalidated!");
return true;
});
} catch (ex) {
console.log("Exception: " + ex.message);
}
This fragment relies on a public Progress web application with a CustomerService that has a JSDO Catalog.
The call to getSession() instantiates and authenticates a JSDOSession. After it is successful, a JSDO is created for
the Customer resource. The fill() method is then called to read the Customer
resource data. The second then() handles the result of
fill(), and on success contains all of the
Customer records. For security, it also invalidates the
JSDOSession so that it cannot be reused. The final
then() handles the results of
JSDOSession.invalidate(). The catch block handles any exception thrown within the try block.
For more information on:
- These stand-alone functions — See getSession( ) stand-alone function.
- The
JSDOSessionmethods that these functions invoke — See the progress.data.JSDOSession class description. - Instantiating a JSDO instance and the features it provides — See the progress.data.JSDO class description.
- Implementing JSDO method calls to invoke operations on Data Object resources — See CRUD and Submit operations and Access custom Invoke operations.
- Managing login sessions to support JSDO access to network resources — See Manage JSDO login sessions.