All-
Having strange behavior with the NetSuiteService object and 2.6 beta WS. Code below works fine with WSDL 2.5 - with WSDL 2.6 all properties of the NetSuiteService object are null after a successful login. Most of this code was lifted from the ERP example...
Am using .NET framework 2.0.50727
Any shared experience would be greatly appreciated...
Thanks!
Scott
// constructors public NSInterface(string Username, string Password, string AccountNumber) { // set defaults _IsAuthenticated = false; _NetsuiteURL = "https://webservices.netsuite.com/services/NetSuitePort_2_6"; // setup the netsuite service _Service = new NetSuiteService(); _Service.Timeout = 1000*60*60*2; _Out = new Logger("info"); // set variables _Username = Username; _Password = Password; _AccountNumber = AccountNumber; } // methods public void login(bool isAuto) { if ( !_IsAuthenticated ) { // Check whether this is a forced login as part of another operation if ( isAuto ) _Out.writeLn( "nYou need to first login before invoking this operation ..." ); // Enable client cookie management. This is required. _Service.CookieContainer = new CookieContainer(); _Service.Url = _NetsuiteURL; // Populate Passport object with all login information Passport passport = new Passport(); RecordRef role = new RecordRef(); passport.email = _Username; passport.password = _Password; role.internalId = "18"; //need to move this to the constructor passport.role = role; passport.account= _AccountNumber; // Login to NetSuite _Out.info( "nLogging into NetSuite" ); _Out.info( " Username: " + passport.email ); _Out.info( " Account: " + passport.account ); try { // invoke the login method Status status = (_Service.login(passport)).status; // Process response if (status.isSuccess == true) { _IsAuthenticated = true; // this is where it bombs out due to a null _Service.sessionInfo _Out.info("nThe user with nsKey=" + _Service.sessionInfo.userId + " was logged in successful and a new session has been created."); } else { // Should never get here since any problems with the // login should have resulted in a SOAP fault _Out.error(getStatusDetails(status)); } } catch ( System.Web.Services.Protocols.SoapException ex ) { // Get the fault type. It's the only child element of the detail element. String fault = ex.Detail.FirstChild.Name; // Get the list of child elements of the fault type element. // It should include the code and message elements System.Collections.IEnumerator ienum = ex.Detail.FirstChild.ChildNodes.GetEnumerator(); String code = null; String message = null; while (ienum.MoveNext()) { XmlNode node = (XmlNode) ienum.Current; if ( node.Name.Equals( "code" ) ) code = node.InnerText; else if ( node.Name.Equals( "message" ) ) message = node.InnerText; } _Out.fault( fault, code, message ); // Check whether the session is invalid if ( code.Equals( "INVALID_SESSION" ) ) { _IsAuthenticated = false; } } finally { // clean up code if needed } } }