Android Question WebServices Error

Luca Tonelli

Member
Licensed User
Hello

I have to consume a simple webservices written in Asp.net
When I call it, the error Response Error returns. Reason bad request, Response

B4X:
        Dim job As HttpJob
        Dim Url As String="http://192.168.1.71/retailws.asmx"
        job.Initialize("Job",Me)
        Dim Xmla As String=$"
                                <?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>
                                            <Login xmlns="http://192.168.1.71/" />
                                      </soap:Body>
                                </soap:Envelope>
                            "$
        job.PostString(Url,Xmla)
        job.GetRequest.SetHeader("SOAPAction", "http://192.168.1.71/Login")
        job.GetRequest.SetContentType("text/xml; charset=utf-8")
The libraries used are: OkHttp V 1.20 OkHttpUtil V.2.61

The Webservices is :
upload_2018-4-30_1-10-4.png
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try this:
B4X:
Dim job As HttpJob
        Dim Url As String="http://192.168.1.71/retailws.asmx"
        job.Initialize("Job",Me)
        Dim Xmla As String=$"<?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>
                                            <Login xmlns="http://192.168.1.71/" />
                                      </soap:Body>
                                </soap:Envelope>"$
        job.PostString(Url,Xmla)
        job.GetRequest.SetHeader("SOAPAction", $""http://192.168.1.71/Login""$)
        job.GetRequest.SetContentType("text/xml; charset=utf-8")
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
the event is called
Sub Activity_Resume
Huh? Where did that come from? Looking at your code posted initially it should be more like
B4X:
Wait For (job) JobDone(job As HttpJob)
Also, if you're using Wait For, you can change
B4X:
job.Initialize("Job",Me)
to
B4X:
job.Initialize("",Me)

BTW,
Now when I run Wait For (job) JbDone (job As HttpJob) does not exit Wait
was JbDone just a spelling mistake on the forum post? If your spelling was like this in your code, Wait will not exit (there is no JbDone event).

Resource: https://www.b4x.com/android/forum/threads/b4x-okhttputils2-with-wait-for.79345/#content
 
Upvote 0
Top