Android Question HttpJob PostString with ProgressBar

energypf

Member
Licensed User
Longtime User
Hi, I was converting an old project that invoked a webservice and through the property HttpUtils2Service.progressSub = "DownloadProgress" and the
B4X:
 Sub DownloadProgress (tmp As ProgressStatus)
ProgressDialogHide
If ProgressBar1.Visible = False Then
lblDownload.Visible = True
ProgressBar1.Visible = True
End If
ProgressBar1.progress = Round ((tmp.downloaded * 100) /tmp.total)
End Sub
I could see the progress of the download. Unfortunately this property is no longer present in the new libraries. How can I progress after a PostString call?

B4X:
    Dim InviaAWebService As HttpJob
    Dim RequestSoapXML As String
    
    InviaAWebService.Initialize("DownloadReferto",Me)
    
    Url1 = "https://xxxxxxxx/xxxxxxx.asmx"
  
    RequestSoapXML = _
            "<?xml version='1.0' encoding='utf-8'?>" & _
               "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" & _
                    "<soap:Body>" & _
                        "<GetReport xmlns='http://xxxxxxxxx.xxx/'>" & _
                            "<CodFisc>AAA</CodFisc>" & _
                            "<Password>BBB</Password>" & _
                            "<Pin>CCC</Pin>" & _
                        "</GetReport>" & _
                    "</soap:Body>" & _
                "</soap:Envelope>"
    
    
    InviaAWebService.PostString(Url1,RequestSoapXML)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Tip: use smart strings literal:
B4X:
    RequestSoapXML = $"<?xml version='1.0' encoding='utf-8'?>
               <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
                    <soap:Body>
                        <GetReport xmlns='http://xxxxxxxxx.xxx/'>
                            <CodFisc>AAA</CodFisc>
                            <Password>BBB</Password>
                            <Pin>CCC</Pin>
                        </GetReport>
                   </soap:Body>
                </soap:Envelope>"$

Check this: https://www.b4x.com/android/forum/threads/download-huge-files-with-httputils2.30220/#content

You need to modify DownloadService to download with PostString instead of j.Download.
 
Upvote 0

energypf

Member
Licensed User
Longtime User
Thanks Erel, unfortunately I had already tried to edit the file, but I was not able to. Do you have any examples already edited? Thank you
 
Upvote 0

energypf

Member
Licensed User
Longtime User
B4X:
Type DownloadData (url As String, Target As Object, EventName As String, PostString As String)

Public Sub StartDownload(data As DownloadData)
    If jobs.ContainsKey(data.url) Then
        Log("Ignoring duplicate request.")
        Return
    End If
    Dim J As HttpJob
    J.Initialize(data.url, Me)
    Dim tag As JobTag
    tag.Initialize
    tag.data = data
    J.tag = tag
    jobs.Put(data.url, J)
     J.PostString(data.url,data.PostString)
    If timer1.Enabled = False Then StartTimer(data.Target)
End Sub
 
Upvote 0
Top