HI,
I am working on
VB.Net.My program connects to the remote host, once the
login values are verified, it sends the SessionID. My problem is Although in
"Logindom" variable( in the Auto window), I see it has child nodes, but nodes
= Nothing.. Since, I need to copy the value of SessionID in my next function,
how can I read the value of Node. If I do, LoginDom.InnerText, then I
get"SuccessSessionID", if there is no way to get node value then should I use
Trim to trim success from the result and use it in another function
Private Function ParseLoginResponse(ByRef loginDom As XmlDocument) As Boolean
' See if the login was successful. If so, get the SessionID.
' Otherwise, log the error.
'assign a avalue to it, initialize it in previous method. If you set
the property of an object in one event handler, once the event is finished
with the setting of the property, that value is lost unless you save the
whole object in a session variable. So in your code, you only set the value
in Button_Click1 but didn't save the changes anywhere. When Button_Click2's
event is executed, you start from the same uninitialized property of the
object.
Try
ParseLoginResponse = False
Dim filterDoc As New XmlDocument
'Instantiate an XmlNamespaceManager object
Dim nsmgr As XmlNamespaceManager
nsmgr = New XmlNamespaceManager(filterDoc.NameTable)
nsmgr.AddNamespace("ns", "urn:schemas -tms:LoginResponse")
'Dim node As XmlDocument
'node = New XmlDocument
'**************
Dim node As XmlNode
' Setup the Dom to use XPath queries and also setup
' an Xml namespace prefix for use in the XPath queries.
node =
loginDom.DocumentElement.SelectSingleNode("ns:Logi nResponse/ns:Status", nsmgr)
'Console.WriteLine("Login successful: " & node.Value)
If Not loginDom.InnerText Is Nothing Then
' The login was 100% successful so get the SessionID.
'new Feb 14
'If node Is Nothing Then
'for testing
node =
loginDom.SelectSingleNode("ns:LoginResponse/ns:SessionID", nsmgr)
'Console.WriteLine("Login successful: " & node.InnerText)
'Console.WriteLine("Login successful: " & node.Name)
Console.WriteLine("Login successful: " & loginDom.InnerText)
'Feb 20
'Console.WriteLine("Login successful: " & node.Value)
'Add after knowing which omethod contains the value of
SessionID
'g_SessionID = node.InnerXml OR
'g_SessionID = loginDom.InnerXml.TrimEnd
'new for testing Feb16 took out on Feb 23
'Dim resultImport As XmlNode
'resultImport = filterDoc.ImportNode(node, True)
'filterDoc.AppendChild(resultImport)
'Return True
'g_SessionID = loginDom.Value
ParseLoginResponse = True
'Feb23 commented out
'Console.WriteLine("Login successful: " & loginDom.InnerXml)
'Console.WriteLine("Login successful: " & node.)
'Feb14
Else
'The login was not 100% successful
node =
loginDom.SelectSingleNode("ns:LoginResponse/ns:SystemMessage")
'Console.WriteLine("Login unsuccessful: " & node.InnerText)
End If
Catch ex As Exception
MsgBox("Can't parse login information" & vbCrLf & ex.Message)
loginDom = Nothing
'node = Nothing
End Try
End Function
Private Sub btQueryAssetList_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btQueryAssetList.Click
Dim queryAssetListXml As String
Dim queryAssetListResponse As XmlDocument
queryAssetListXml = "<?xml version='1.0' ?>" & _
"<QueryAssetList2
xmlns=""urn:schemas-tms:QueryAssetList2"">" & _
"<SessionID>" & g_SessionID & "</SessionID>" & _
"</QueryAssetList2>"
queryAssetListResponse = SendXmlRequest(queryAssetListXml)