>我需要为我的b4a项目添加一个网络服务..请帮助我,我真的不知道该怎么做。我已经尝试了 https://www.b4x.com/android/forum/threads/how-call-a-web-services-in-b4a.10577/和 https://www.b4x.com/android/forum/threads/web-service-consume-in-b4a.17446/但它不起作用
您的网络服务是什么?(肥皂或休息或XmlRPC(
对于肥皂用户 https://www.b4x.com/android/forum/threads/soap-is-easier-with-soap-class.56164/#content
对于 XmlRPC,请使用 https://www.b4x.com/android/forum/threads/manage-xmlrpc-with-okhttputils-easily-b4x.82527/#content
为了休息使用OkHttp也
你可以使用 httpjob 。 将这两个库添加到您的 b4a 中:Okhttp 和 okhttputils2 。 搜索 B4X 论坛以获取 httjob 示例。
Dim job1 As HttpJob
DIm SoapXML As String= your xml here
job1.Initialize("Job1", Me)
job1.poststring (webserviceaddress, SoapXML)
job1.GetRequest.SetContentType("text/xml")
您可以在 jobdone Event 上获取结果,并使用 SaxXML解析器库对其进行解析
Sub JobDone (Job As HttpJob)
If Job.Success = True Then
parser.Parse(Job.GetInputStream ,"Parser")
Else
Log("Error: " & Job.ErrorMessage)
End If
Job.Release
End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
...
End Sub