1
我需要連接到Web服務來執行事務。爲此我使用NetSuiteService:System.Web.Services.Protocols.SoapHttpClientProtocol
類。爲了獲得服務,我需要登錄。我不想創建Web服務,並在每次需要執行事務時都進行登錄。我有這樣做的功能。要知道何時登錄超時
private static NetSuiteService Service { get; set; } = new NetSuiteService();
private static void isOnline()
{
if (Service.applicationInfo != null) return;
Service.CookieContainer = new CookieContainer();
Service.applicationInfo = new ApplicationInfo();
var passport = new Passport();
passport.account = "aaa";
passport.email = "bbb";
var role = new RecordRef();
passport.password = "999";
try
{
var status = Service.login(passport).status;
if (!status.isSuccess)
{
Log.ErrorFormat("can't login to NetSuite - {0}", status.statusDetail);
Service.applicationInfo = null;
}
}
catch (Exception ex)
{
Log.Error("NetSuite login err", ex);
}
}
但是有時候我的連接被時間掉了,我需要重新連接。在這種情況下,我在執行交易時有例外。
是否有可能以某種方式知道我的會話在進行交易之前是否超時?