B4J Question Issue with Parse ...

Gary Miyakawa

Active Member
Licensed User
Longtime User
Before I build a stripped down copy of my code I thought I would ask..

I'm writing a tool to query status of some video conferencing equipment. It's using REST protocol and all that is working fine. The problem come in when I'm trying to parse the returned information. It's in .xml format so I'm attempting to use the "parse" method.

The sequence is as follows.

1. Query the device and get the xml returned. (all good)
2. Use parse to find a "link" element that points to sub information (all good)
3. Using a different (J1) httpjob (in separate sub) query for the "link" information
4. Using "Wait for" ...
5. When I step after the wait, I goes to the FIRST query parser_StartElement when it should go to the J1 parser_StartElement.

Of course, it misses the information at that point and what is returned in the Parser_startelement is all nulls.

What is crazy is, when (in the same code) it queries the second device, the code works correctly.

I'm guessing it's an initialization issue but not sure how to debug it more.

Any help would be greatly appreciated.

Cheers,

Gary Miyakawa
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
sounds really easy to solve, unfortunately with code to look at, it doesnt have to be a stripped down version; just a snippet, would be easier to help you
 
Upvote 0

Gary Miyakawa

Active Member
Licensed User
Longtime User
So, The code starts with Button Click
That queries the server.
wait for returning information and process using parser_StartElement
When we find a "Link" entry we query it using SubParserCall
When we get down to the "Wait", I'm expecting the XML entry to go to SubParserCall_StartElement but it jumps to Parser_StartElement.


Thanks for lookin at this !

Gary M



Parser J:
    Private parser As SaxParser
    Private SubParser As SaxParser

Sub Button1_Click()

    Dim j As HttpJob
       
    j.Initialize("j",Me)
    j.Username = "garym"
    j.Password = "xxxxxxx"
    j.Download("https://10.10.10.111:8443/api/rest/active-calls")
    Wait for (j) JobDone (j As HttpJob)                                               'Query server, use Wait to process each of the returning xml entries
    If j.Success Then
        Log(j.GetString.Length)
        If j.GetString.Length > 500 Then
            parser.Parse(StringToInputStream(j.GetString), "Parser")
        Else
            TableView1.Items.Clear
            NoActiveCalls("")
        End If
    End If
    j.Release
   
' Here we look for the "link" entry
Sub Parser_StartElement (URI As String, Name As String, Attributes As Attributes)
Select Case Name
    Case "link"
            If (Attributes.GetValue2("", "title") = "Call Info") Then
                SubParsarCall("", Attributes.GetValue2("", "href"))   'When link is found, query again with new link'
            End If
    End Select
End Sub

'Query with Link information
Sub SubParsarCall (Which As String, linkstring As String)
    Dim j1 As HttpJob
    j1.Initialize("", Me2)
    j1.Username = "garym"
    j1.Password = "xxxxxxx"
    j1.Download(linkstring)

    Wait for (j1) JobDone (j1 As HttpJob)      'This is where it jumps to 'Parser_StartElement instead of SubParserCall_StartElement'
    If j1.Success Then
        Log("SPC:" & j1.GetString.Length)
        If j1.GetString.Length > 500 Then
            SubParser.Parse(StringToInputStream(j1.GetString), "SubParser")
            Log(j1.GetString)
        Else
            Log("No Active Calls")
            TableView1.Items.Clear
        End If
    End If
    j1.Release
End Sub

Sub SubParser_StartElement (URI As String, Name As String, Attributes As Attributes)
Select Case Name
    Case "ns3:media-encryption-algorithm"
        MediaEncryptionAlgorithm = Attributes.GetValue2("", "text")
End Select
 
Last edited:
Upvote 0

Gary Miyakawa

Active Member
Licensed User
Longtime User
I believe they are two different event names.

1. parser
2. SubParser

Based on the SaxParser definitions.

Is there something else I need to do for this?

Thanks
 
Upvote 0

Gary Miyakawa

Active Member
Licensed User
Longtime User
Sorry, When I made my "code" for here, I accidentally put SubParserCall_Start when the event is actually called SubParser.
 
Upvote 0
Top