10.07.2015 Views

SuiteTalk (Web Services) Platform Guide - NetSuite

SuiteTalk (Web Services) Platform Guide - NetSuite

SuiteTalk (Web Services) Platform Guide - NetSuite

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Web</strong> <strong>Services</strong> SecuritySession Management81maintained, you will receive an InvalidSessionFault —PLEASE_LOGIN_BEFORE_PERFORMING_ACTION.ExampleThe following code shows the cookie information returned in the login response.HTTP/1.1 200 OKDate: Wed, 18 May 2008 18:43:27 GMTServer: Oracle-Application-Server-10g/9.0.4.0.0 Oracle-HTTP-ServerSet-Cookie: NS_VER=2008.1.0; domain=joe.corp.netsuite.com; path=/Vary: User-AgentSet-Cookie: JSESSIONID=ac101fae1f4312dfxxx062fc829447eaa00c3dcd70af41d; Path=/Set-Cookie: lastUser=TSTDRV198400_935_3; Expires=Wed, 25-May-2008 17:42:24 GMT; Path=/Cache-Control: privateKeep-Alive: timeout=150, max=1000Connection: Keep-AliveTransfer-Encoding: chunkedContent-Type: text/xml; charset=utf-8For each subsequent request, all of the cookies must be returned in the HTTP header tomaintain the session as follows:Sample Code (C#)<strong>NetSuite</strong>Service nss = new <strong>NetSuite</strong>Service();nss.Url = https://webservices.netsuite.com/services/<strong>NetSuite</strong>Port_2008_1_0 ;nss.CookieContainer = new CookieContainer();Sample Code (Java with Axis 1.3)<strong>NetSuite</strong>ServiceLocator nss = new <strong>NetSuite</strong>ServiceLocator();nss.setMaintainSession(true);Reusing Session IDs During LoginEndpoints starting with v2008_1 support the reuse of session IDs. If you have a valid session atthe time you invoke login, <strong>NetSuite</strong> transparently connects you to your existing session insteadof creating a new session. Reusing an existing session (returning the same JSESSIONID)eliminates the overhead of generating a new session and thereby improves performance.For multi-threaded applications, the primary benefit to session ID resuse is that a threadexecuting a login does not invalidate sessions of existing threads. Instead, multiple threadsshare the same reference to a session. The trade-off is that the session returned by login may bein use, and as expected, any attempt to execute an operation with a busy session will result in aWS_CONCUR_SESSION_DISALLWD error.Note that the strategy for sharing a single set of credentials across threads remains the same asit was for endpoints older than v2008_1. Because only one session can exist for a given set ofcredentials, and a session cannot be used for more than one operation at a time, multiplethreads sharing those credentials should synchronize usage of the session. If collisions are notexpected often, a simpler alternative is to implement a retry strategy for operations that fail dueto a WS_CONCUR_SESSION_DISALLWD error.Important: Be aware that session ID reuse does not apply to the following:<strong>SuiteTalk</strong> <strong>Platform</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!