Calling WebService instance in Android

In some cases, we may need to interact with MySQL or Oracle database. The first reaction of some friends is to directly load the driver in Android, and then add, delete, modify and check the data. I personally do not recommend this approach. First, mobile phones are not computers after all. Operating a large amount of data takes time and electricity; Second, the flow is as expensive as gold. I personally recommend using Java or PHP development interfaces or writing WebService to add, delete and query the database, and then Android calls the interface or WebService to interact with the data. This article will explain how to call the WebService provided by the remote server in Android.

Since we are calling WebService, we first build a WebService server.

The following is a demonstration of how to query the number home of the WebService service through the mobile phone number home provided by the website

Call address http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?op=getMobileCodeInfo 。

First, save the request message in the XML file, and then replace the request parameters with $, as follows:

mobilesoap. xml

Secondly, design the mainactivity layout file, main xml

Mainactivity is posted below,

Calling WebService in Android is relatively simple: request WebService, get the data of the service response, parse it and show it.

Finally, note that because you need to access the network, you need to add permissions

Through the above simple example, I believe you have learned how to call WebService in Android, and finally run the result:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>