Android Question HELP WEB SERVICE

felixjavierdiaz

Member
Licensed User
Longtime User
If anyone can help me I thank you.I have a Web service to which I need to submit multiple records that I have stored in the database, but I need to send one waiting for a response from each submitted record.To make a for and send data does it in a way very fast and I cannot control the response of each submitted record and those records are lost to me.IE I need to submit a registration and the confirmation of the same, once you have the confirmation to continue with the next record and so on up to send all records.This is the code I am using

Sub Bclientes_Click
Dim cadena As String
URL = "http://tableroeca.sytes.net:81/conelec/conelec_ws.dll/dato_clientes?"
Dim request As HttpRequest
For i = 0 To 5
HttpClient1.Initialize("HttpClient1")
acta = "1"&i
cadena = "ACTA=1"&i&"&ORDEN=O"&i& "&OBS=OBS"&i& "&LECTURA=L"&i
cadena = cadena.Replace(" ", "%20")
request.InitializeGet(URL&cadena)
request.Timeout = 10000
HttpClient1.Execute(request, 1)= False Then Return
Next
End Sub

hanks in advance to those who can help me.
Best regards

fdm
 

felixjavierdiaz

Member
Licensed User
Longtime User
Thanks Erel.La really don't understand when you say: You can add all the HttpJobs to a list and then submit the first one.When it completes submit the next one.I was looking at the examples link but can not find what you mention.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Something like:
B4X:
Dim jobs As List 'process global variable
jobs.Initialize

'add the jobs to the list
Dim j1 As HttpJob
j1.Initialize(...)
j1.Tag = ... 'store the link in the Tag property
jobs.Add(j1)

'submit the first one
j1.Download(j1.Tag)

Sub JobDone(j As HttpJob)
 'work with the response

 'submit the next one
 jobs.RemoteAt(0)
 If jobs.Size > 0 Then
   Dim jj As HttpJob = jobs.Get(0)
   jj.Download(jj.Tag)
 End If
End Sub
 
Upvote 0

Octavio Diaz

Member
Licensed User
Longtime User
Something like:
B4X:
Dim jobs As List 'process global variable
jobs.Initialize

'add the jobs to the list
Dim j1 As HttpJob
j1.Initialize(...)
j1.Tag = ... 'store the link in the Tag property
jobs.Add(j1)

'submit the first one
j1.Download(j1.Tag)

Sub JobDone(j As HttpJob)
'work with the response

'submit the next one
jobs.RemoteAt(0)
If jobs.Size > 0 Then
   Dim jj As HttpJob = jobs.Get(0)
   jj.Download(jj.Tag)
End If
End Sub


Hello Erel and felix, if I had a similar problem but with poststring, the list of jobs can do it? thanks!
 
Upvote 0
Top