我需要在我的b4a项目中添加一个web服务..请帮助我,我真的不知道该怎么做..我已经尝试了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/但它确实如此工作
答案 0 :(得分:0)
您的网络服务是什么? (Soap或Restful或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也
答案 1 :(得分:0)
你可以使用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事件上获得结果。并使用saxxmlparser库解析它
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