Sunday, September 16, 2018

Get the session timeout of the application in Netsuite Web Services

Following sample code snippet counts number of seconds before the session of an application times out.

 

Using Web Services, this creates a web session. Running a process in the application is only allowed within the remaining session. The process will terminate if the execution time exceeds the allowable time for the web service.

 

Here's a way to catch the remaining session time:

 

Sample code snippet in C#:

 

using System.Web.SessionState; //add this namespace to access the class for session timeout

 

//Utilize Netsuite web service

NetSuiteService _service = new NetSuiteService();

_service.CookieContainer = new CookieContainer();

Passport passport = new Passport();

passport.account = "TSTDRVxxxxx";

passport.email = "johndoe@netsuite.com";

RecordRef role = new RecordRef();

role.internalId = "3";

passport.role = role;

passport.password = "password";

Status status = _service.login(passport).status;

_service.login(passport);

 

//Create a string to store the remaining session in seconds

HttpSessionState ss = HttpContext.Current.Session;

string myTimeout = "Timeout at: " + ss.Timeout.ToString() + " seconds";

 

 

No comments:

Post a Comment