Android Question HttpJob returns empty InputStream from Job.GetInputStream

ostau

Member
Licensed User
Longtime User
Hallo there,
I want to use the solution with HttpJob and HttpUtils2Service, which is provided as an example application by Erel.
I built a .Net-Webservice, Parameters are supplied by POST-Method.
It returns a XML-String, which will parsed with SAX-Parser.

Here ist the snippet of the modified sample code:

....
WebService_URL = "http://192.168.80.22/PMDSService/Service.asmx/getZusatzeinträge"
WebService_Parameters = "IDPflegeplan=xx"
Dim job1 As HttpJob
job1.Initialize("MyJob", Me)
job1.PostString(WebService_URL, WebService_Parameters)

End Sub


Sub JobDone (Job As HttpJob)

If Job.Success = True Then
Dim x As String
x = Job.GetString

Dim xx As InputStream
xx = Job.GetInputStream

.....

The result as string is correct, the InputStream is empty.

Any ideas, what could be wrong?

Kind regards, Oskar
 

sorex

Expert
Licensed User
Longtime User
works fine here. the log shows this...

LogCat connected to: 192.168.56.101:5555
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
XOMDocument is initialized
Name = Sander admin
Passwort = 3FABD40C9AF03343E4CFDB5D4B68A8ED
ID = 9d88547f-e1f0-402e-a9f4-a6c25c827de8
Kürzel = admin
IDBerufsstand = e969d3f5-f3ca-4c34-a4c9-b65b380601aa
Name = Saglik Astrid
Passwort = 821D5311AA0374AACF78980388308421
ID = 1e58709d-aea4-419a-9a76-34241f4452ce
Kürzel = aj
IDBerufsstand = 00000000-0000-0000-0002-000000000001
Name = Saalbach Brigitte
Passwort = 823EAE0D794A154B6D12B53E1296A627
ID = 1b6e88cd-6ff3-4531-800b-0af324dcab63
Kürzel = bs
IDBerufsstand = acfb447f-d853-4701-88c7-d20bd31ffb31
 
Upvote 0

ostau

Member
Licensed User
Longtime User
I copied the sub and copied the xml string builder in activity_create
Thanks. Seems I left the Sub before Activity_Resume.
The Parser is VERY usefull and quick. Exactly what I Need.
Appriciate your help
 
Upvote 0

ostau

Member
Licensed User
Longtime User
no problem, have fun with it.
Hallo sorex,

I know, the topic of this thread has been to XOM-Parser changed, but I'm not sure, if I should open a new thread.
So I'm continuing this one.

I changed the the Parsers code, to parse the result of my real webservice result (see attached file).
B4X:
Sub XOMBuilder1_BuildDone(XOMDocument1 As XOMDocument, Tag As Object)
'Gibt die Tabelle als List of Maps zurück
Dim RootElement As XOMElement
Dim xmlTables As XOMElements
Dim xmlcTables As XOMElements
Dim xmlRows As XOMElements
Dim xmlcRows As XOMElements
Dim xmlValues As XOMElements
Dim xmlcValues As XOMElements
Dim xmlTable As XOMElement
Dim xmlcTable As XOMElement
Dim xmlRow As XOMElement
Dim xmlcRow As XOMElement
Dim xmlValue As XOMElement
Dim xmlcValue As XOMElement

Dim cName As XOMElement
Dim cValue As XOMElement
Dim cType As XOMElement

Dim dt As Long : dt = 0
Dim m As Map : m.Initialize
Dim l As List : l.Initialize

If XOMDocument1.IsInitialized Then
Log("XOMDocument is initialized")
RootElement=XOMDocument1.RootElement

xmlTables = RootElement.GetChildElementsByName("tables")
For i1 = 0 To xmlTables.Size - 1
xmlTable = xmlTables.GetElement(i1)
xmlcTables = xmlTable.GetChildElementsByName("cTable")
For i2 = 0 To xmlcTables. Size - 1
xmlcTable = xmlcTables.GetElement(i2)
xmlRows = xmlcTable.GetChildElementsByName("rows")
For i3 = 0 To xmlRows.Size - 1
xmlRow = xmlRows.GetElement(3)
xmlcRows = xmlRow.GetChildElementsByName("cRow")
For i4 = 0 To xmlcRows.Size - 1
xmlcRow = xmlcRows.GetElement(i4)
xmlValues = xmlcRow.GetChildElementsByName("Values")
For i5 = 0 To xmlValues.Size - 1
xmlValue = xmlValues.GetElement(i5)
xmlcValues = xmlValue.GetChildElementsByName("cValue")
For i6 = 0 To xmlcValues.Size - 1
xmlcValue = xmlcValues.GetElement(i6)
m.Initialize
cName = xmlcValue.GetFirstChildElementByName("columnName")
cType = xmlcValue.GetFirstChildElementByName("valueName")
Select Case cType.Value
Case "System.String"
cValue = xmlcValue.GetFirstChildElementByName("valueStr")
m.Put(cName.Value, cValue.Value)
Case "System.Int32"
cValue = xmlcValue.GetFirstChildElementByName("valueInt")
m.Put(cName.Value, cValue.Value)
Case "System.Double"
cValue = xmlcValue.GetFirstChildElementByName("valueDbl")
m.Put(cName.Value, cValue.Value)
Case "System.Boolean"
cValue = xmlcValue.GetFirstChildElementByName("valueBool")
If cValue.Value = "True" Then
m.Put(cName.Value, "1")
Else
m.Put(cName.Value, "0")
End If
Case "System.DateTime"
cValue = xmlcValue.GetFirstChildElementByName("valueDateTime")
DateTime.DateFormat = params.dtFormat
dt = DateTime.DateParse(cValue.Value.Replace("T"," "))
m.Put(cName.Value, dt)
Case "System.Guid"
cValue = xmlcValue.GetFirstChildElementByName("valueGuid")
m.Put(cName.Value, cValue.Value)
Log (cName.Value & "=" & cValue.Value)
End Select
Next
Next
Next
Next
Next
Next
'Kontrolle der Rückgabelist
For k = 0 To l.Size - 1
m = l.Get(k)
For x = 0 To m.Size - 1
Log (m.GetKeyAt(x))
Log (m.GetValueAt(x))
Next
Next
Else
' XOMDocument1 will be uninitialized if an error has occurred
Log("An error has occured and the XOMDocument has NOT been initialized")
Log(LastException.Message)
End If
SaveListToDB(CallbackActivity, l)
End Sub

I get the RootElement, but the size of the XOMElement xmlTables is 0, so nothing get be parsed. What's wrong with my code?
Kind regards, Oskar
 

Attachments

  • getBenutzerShort.xml
    104.8 KB · Views: 286
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…