|
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 |