The previous article has introduced the Web service and its related knowledge (Android development WebService), I believe some friends have patience to try to call the Web service in the Android application. This article explains and demonstrates the development of Web service for the Android platform through a simple example.
Ksoap2-android Introduction
Invoking Web service on the Android platform relies on Third-party class library ksoap2, a SOAP WEB service client development package that is used primarily for resource-constrained Java environments such as applets or J2ME applications (cldc/cdc/ MIDP). Carefully read the introduction of KSOAP2 you will find that it is not mentioned in the Android platform development, yes, on the Android platform we do not use the KSOAP2 directly, but the use of KSOAP2 Android. KSoap2 Android is an efficient, lightweight soap development package on the Android platform, equivalent to the KSOAP2 porting version on the Android platform.
ksoap2-android jar Pack Download
Ksoap2 Android currently has the latest version of 2.5.4, named Ksoap2-android-assembly-2.5.4-jar-with-dependencies.jar, whose download address is: http:// Code.google.com/p/ksoap2-android/, after entering the page, click on the "Downloads" tab, as shown in the following image:
Below the "Downloads" page, find the purple link shown in the following figure, then right-click on the link and find the relevant download to download. The download items displayed in the right menu vary according to the browser, such as the 360 browsers I use, right-click on the key, and choose "Download using 360 secure browser" to pop up the download Save dialog box.
Android platform invoke Web service sample
Here is an example of how to invoke Web Service on the Android platform. Now that you want to invoke the Web service, you must have a Web service. We chose to use the Web service, which was used in the previous article, to query the place where the cell phone number belongs, and its WSDL is http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl.