Hello,
I have an application working for a few years ago that connects with a server using JSON-Rest web services, it is still not using the ResumableSub method of downloading resources, until now I had a huge JobDone Sub where I have a Select -Case statement filtered by Job.JobName in order to get the correct event in each case.
But now I am rewriting the code using Resumable Subs(I have more than 40 web methods to rewrite) and I´m getting a problem in the HttpJob module, at the begining all was working fine, I use the wait for statement and every web request have its own sub and returns its data in the right way, but I have started to get an error in the HttpJon module:
The problem is in this line of the HttpJob module:
tr.Initialize2(File.OpenInput(HttpUtils2Service.TempFolder, taskId), Encoding)
It seems that there is a problem with the temporal file.
An example of one of the subs that download data from the server:
And I use the sub in this way:
What could be the problem?
I have an application working for a few years ago that connects with a server using JSON-Rest web services, it is still not using the ResumableSub method of downloading resources, until now I had a huge JobDone Sub where I have a Select -Case statement filtered by Job.JobName in order to get the correct event in each case.
But now I am rewriting the code using Resumable Subs(I have more than 40 web methods to rewrite) and I´m getting a problem in the HttpJob module, at the begining all was working fine, I use the wait for statement and every web request have its own sub and returns its data in the right way, but I have started to get an error in the HttpJon module:
B4X:
InsertMaps (first query out of 1): INSERT INTO [tblManagementIncidenceTypes] ([Code], [GroupCode], [Description]) VALUES (?, ?, ?)
InsertMaps (first query out of 1): INSERT INTO [tblManagementIncidenceTypes] ([Code], [GroupCode], [Description]) VALUES (?, ?, ?)
Error occurred on line: 129 (HttpJob)
java.io.FileNotFoundException: /data/user/0/com.mbm.distromel.incidencias/cache: open failed: EISDIR (Is a directory)
at libcore.io.IoBridge.open(IoBridge.java:459)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:209)
at com.mbm.distromel.incidencias.httpjob._getstring2(httpjob.java:384)
at com.mbm.distromel.incidencias.httpjob._getstring(httpjob.java:169)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:19)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:240)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:132)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1717)
at android.os.Handler.handleCallback(Handler.java:743)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5546)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:682)
Caused by: android.system.ErrnoException: open failed: EISDIR (Is a directory)
at libcore.io.IoBridge.open(IoBridge.java:449)
... 23 more
The problem is in this line of the HttpJob module:
tr.Initialize2(File.OpenInput(HttpUtils2Service.TempFolder, taskId), Encoding)
It seems that there is a problem with the temporal file.
An example of one of the subs that download data from the server:
B4X:
Sub GetGarbages(garbages As List) As ResumableSub
Dim job1 As HttpJob
Dim list1 As List
Dim p As JSONParser
Dim ret As Boolean
'Send a GET request
garbages.Initialize
list1.Initialize
job1.Initialize("GetGarbages", Me)
job1.Username=User
job1.Password=Password
job1.Download(UrlGetGarbages)
Log(job1.GetString)
Wait For (job1) JobDone (job1 As HttpJob)
If job1.Success Then
If job1.GetString.StartsWith("[") Then
p.Initialize(job1.GetString)
Else
If job1.GetString.IndexOf("[") > -1 Then
p.Initialize(job1.GetString.SubString(job1.GetString.IndexOf("[")))
Else
p.Initialize(job1.GetString)
End If
End If
'Error android 2.3
list1 = p.NextArray
Dim map1 As Map
For n=0 To (list1.Size-1)
map1 = list1.Get(n)
Log(map1)
Dim garbage As CGarbage
garbage.Initialize
garbage.garbage=map1.Get("Garbage")
garbage.GarbageId=map1.Get("GarbageId")
garbages.Add(garbage)
Next
Else
Try
Log("Error GetGarbages: " & job1.ErrorMessage)
Logger.SaveMessage("GetGarbages Error",job1.ErrorMessage)
Catch
ToastMessageShow("Error GetGarbages: " & job1.JobName, True)
End Try
End If
ret=job1.Success
job1.Release
Return ret
End Sub
And I use the sub in this way:
B4X:
Dim garbagesList As List
garbagesList.Initialize
wait for (servGet.GetGarbages(garbagesList)) Complete (Result As Boolean)
If Result=True Then
AppDBUtils.SaveGarbages(AppDBUtils.GetSQLInstance,garbagesList)
End If
What could be the problem?