Logout()


Required final call to close a session.

Public Function Logout(ByVal SessionID As String) As Integer

Parameters

SessionID
String - GUID
The current session's GUID in string format. This is a 32-character hexidecimal string in the format: 00000000-0000-0000-0000-000000000000. This is the value returned by the Login() function.

Returns

SessionTime Integer 
Length of session in milliseconds.

Remarks

Be sure to always Logout() of sessions. Each account has a limited number of allowed simultaneous sessions. If the Logout() function is not called, the session will not be properly closed.

Sessions will time out when the timeout value between API calls is exceeded. The default timeout value is 60 seconds.

Example

Visual Basic

Imports System.Xml
Imports System.Web.Services.Protocols

Class ErrorInfo
    Public ErrorCode As Short
    Public ErrorString As String
    Public ErrorItem As String
    Public ErrorMessage As String
End Class

Partial Class _Default
    Inherits System.Web.UI.Page
    Private ecgridos As New net.ecgridos.ECGridOSAPIv2
    Private SessionID As String

    Protected Sub TradingPartners_Click(ByVal sender As Object, _
                                        ByVal e As System.EventArgs) _
                                        Handles TradingPartners.Click
    SessionID = StartSession()
   
If
 SessionID.length > 0 Then
        GridView1.DataSource = _
        ecgridos.TPList(SessionID,False)
        GridView1.DataBind()
        EndSession()
        End If
    End Sub

    Private Function StartSession() As String
        Dim SessionID As String
        Dim ErrorInfo As ErrorInfo
        Try
            SessionID = ecgridos.Login(LoginName.Text, Password.Text)
            Return SessionID
        Catch ex As SoapException 'Note that the default is Exception
            ErrorInfo = CatchException(ex)
            Return ""
        End Try
    End Function

    Private Function EndSession(ByVal SessionID As String) As Integer
        Dim SessionTime As Integer
        SessionTime = ecgridos.Logout(SessionID)
        Return SessionTime
    End Function

    Private Function CatchException(ByVal ex As SoapException) As ErrorInfo
        Dim doc As New XmlDocument
        Dim Node As XmlNode
        CatchException =
New ErrorInfo
        doc.LoadXml(ex.Detail.OuterXml)
        Node = doc.DocumentElement.SelectSingleNode(
"ErrorInfo")
        If Node Is Nothing Then
            'This picks up Framework generated SOAP Exceptions
            With CatchException
                .ErrorCode = -1
                .ErrorString = ex.Message
                .ErrorItem =
""
                .ErrorMessage = ""
            End With
        Else
            'This picks up ECGridOS generated SOAP Exceptions
            With
CatchException
                .ErrorCode =
CInt(Node.SelectSingleNode("ErrorCode").InnerText)
                .ErrorString = Node.SelectSingleNode(
"ErrorString").InnerText
                .ErrorItem = Node.SelectSingleNode(
"ErrorItem").InnerText
                .ErrorMessage = Node.SelectSingleNode(
"ErrorMessage").InnerText
            End With
        End If
    End Function

End Class

EventID: 1002

See Also

Login()
SOAP Exceptions


© 2008-2011, Loren Data Corp.
All rights reserved.
ECGrid is a registered service mark of Loren Data Corp.
ECGridOS is a service mark of Loren Data Corp.