I've been using the following to consume web services:
and the following to process the result:
This has worked fine, but I'd like to implement a way to cancel a job. I'd like to implement the DownloadService, as suggested in this link: https://www.b4x.com/android/forum/threads/download-huge-files-with-httputils2.30220/#content
I understand that I should make the request something like this:
But I can't see how to post the outgoing XML as I did in the first method with "job1.PostString(url, outXML)". Could someone provide a simple example of how to redo Sub btnDownload_Click to send outgoing XML to a web service, plz?
Btw, I tried, after importing the three .bas files - DownloadService, HttpJob, HttpUtils2Service, to just run my existing code. It gave the following error:
- Error occurred on line: 45 (HttpUtils2Service)
- java.lang.RuntimeException: Field: CountingStream not found in: java.lang.Object
I feel fairly certain that this error is because of my prior question of how to formulate the outgoing request.
B4X:
Sub makeHttpRequest(xmlRequestString As String, jobName As String, targ As Object)
Dim outXML As String = xmlRequestString
Dim url As String = "http://www.myurl.com/myvbdotnet.asmx"
Dim job1 As HttpJob
job1.Initialize(jobName, targ)
job1.PostString(url, outXML)
job1.GetRequest.SetContentType("text/xml")
job1.GetRequest.Timeout = 5000
End Sub
and the following to process the result:
B4X:
Sub processJobDone(job As HttpJob)
If job.Success Then
Else
End If
End Sub
This has worked fine, but I'd like to implement a way to cancel a job. I'd like to implement the DownloadService, as suggested in this link: https://www.b4x.com/android/forum/threads/download-huge-files-with-httputils2.30220/#content
I understand that I should make the request something like this:
B4X:
Sub btnDownload_Click
Dim dd As DownloadData
dd.url = link1 '<--- download link dd.EventName = "dd"
dd.Target = Me
CallSubDelayed2(DownloadService, "StartDownload", dd)
End Sub
But I can't see how to post the outgoing XML as I did in the first method with "job1.PostString(url, outXML)". Could someone provide a simple example of how to redo Sub btnDownload_Click to send outgoing XML to a web service, plz?
Btw, I tried, after importing the three .bas files - DownloadService, HttpJob, HttpUtils2Service, to just run my existing code. It gave the following error:
- Error occurred on line: 45 (HttpUtils2Service)
- java.lang.RuntimeException: Field: CountingStream not found in: java.lang.Object
I feel fairly certain that this error is because of my prior question of how to formulate the outgoing request.
Last edited: