Android Question "Jobdone" and WS request, how to ?

Yayou49

Active Member
Licensed User
Hi,

Explainations:
In my activity "Dashboard", I'm calling a sub to request a Web Service (see code 1 below)
In the same activity, to catch the answer of my webservice, I'm using a Sub "Jobdone" linked with a XML parser specific to my WS XML reply. (see code 2 below)

This code works very well for one Web Service.

Question:
Suppose I have 2 differents subs calling 2 differents Web Services.
If I call those 2 sub from the same activity, How to handle both answer ????
Because WS XML reply are not the same for both WS ...

Jobdone1 and jobdone2 ?
How to link jobdone whith each sub ?

I hope my question is clear enough :)


Code1:
B4X:
    Sub WS(Activite)
Dim job1 As HttpJob
    Dim XML As String
    XML = ""
    XML = XML & "<?xml version='1.0' encoding='utf-8'?>"
    XML = XML & "<soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'>"
    XML = XML & "<soap12:Body>"
    XML = XML & "<DashBoard xmlns='http://Site.com/'>"
    XML = XML & "<Act>" & Activite & "</Act>"
    XML = XML & "</DashBoard>"
    XML = XML & "</soap12:Body>"
    XML = XML & "</soap12:Envelope>"
    XML = XML.Replace("'", Chr(34))
    job1.Initialize("JOBSOAP", "Dashboard")
    job1.PostString ("http://Site.com/android.asmx", XML)
    job1.GetRequest.SetContentType("application/soap+xml")
end sub

Code2:
B4X:
Sub JobDone(job1 As HttpJob)
    ProgressDialogHide
    If job1.Success Then
        xmlparser.parse(StringToInputStream (job1.GetString), "Parser")
     Else
        Msgbox(job1.ErrorMessage,"Error")
    End If
    job1.Release
End Sub
 

eurojam

Well-Known Member
Licensed User
Longtime User
You can use the jobname, like:
B4X:
 Select Job1.JobName
         Case "JOBSOAP"
            'do one thing...
         case "Job2"....
            'do something else
        case "job3"
             'goto footbal match....and so on
 
Upvote 0
Top