Developpement:Gestion des sessions
De Wiki1000
Version du 14 mars 2013 à 16:57 par Syfre (discuter | contributions)
Comment obtenir une session ligne 1000 en .NET
Ci-dessous un exemple de récupération d’ID de session en .NET
private string fURL = " http://localhost/service_name/server/"; private string fSociety = ""; private string fLogin = ""; private string fPassword = ""; private string connectstring = "society={0}&username={1}&password={2}&RESSID=2"; private string connectprefix = "rpc.l1000/rest/info.login?"; private string fL1000SID = null; private string fLastErrorMsg = null; public Boolean Connect() { string xmlResult = null; string query = string.Format(connectstring, fSociety, fLogin, fPassword); query = fURL + connectprefix + query; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(query); request.AllowAutoRedirect = false; try { HttpWebResponse wresponse = (HttpWebResponse)request.GetResponse(); StreamReader loResponseStream = new StreamReader(wresponse.GetResponseStream(), Encoding.UTF8); xmlResult = loResponseStream.ReadToEnd(); XmlDocument xmldoc; xmldoc = new XmlDocument(); xmldoc.LoadXml(xmlResult); XPathNavigator nav = xmldoc.CreateNavigator(); XPathNodeIterator iter = nav.Select("methodResponse/params/param/value/string"); iter.MoveNext(); fL1000SID = iter.Current.Value; return true; } catch (Exception ex) { fL1000SID = null; fLastErrorMsg = ex.Message; return false; } finally { } }