Google
Pinterest
Linkedin
YouTube
Skype

Catch Hold of the Lucrative Tips
to Procure Trendy Smartphones

Quick Inquiry

Client Speaks

Client Speaks - Testimonials for Aegis Software


You Are @ >> Home >> Articles >>USE OF KSOAP JAVA API to Excecute WebService

USE OF KSOAP JAVA API to Excecute WebService

KSOAP API is mostly used for Android application to call Web services and use resultant data. As KSOAP is a java API we can also use it in any application where it required to call web service from WSDL.

What is KSOAP ?

KSOAP is a SOAP web service client library for constrained Java environments such as Applets or J2ME applications. The ksoap provides a lightweight and efficient SOAP client library for the Android platform.

It is a fork of the KSOAP library that is tested mostly on the Android platform, but should also work on other platforms using Java libraries. It is still using Java 1.3 so should work fine on J2ME, Blackberry and so on.

Difference Between SOAP & KSOAP

SOAP - SOAP is an XML vocabulary used to describe messaging and remote procedure calls between distributed components. Any modern language that works with the Internet is likely to support both XML and HTTP.

KSOAP - KSOAP is a SOAP API based on kXML, where kXML is a lightweight Java-based XML parser designed to run on limited, embedded systems such as personal mobile devices. It is a pull parser which means it reads a little bit of the document at once.

So, KSOAP was specially designed or developed to deal with small embedded device like mobile devices.

What is WSDL?

Here we are going to provide you brief information about WSDL to understand our example.

WSDL stands for Web Services Description Language.

WSDL is a document written in XML for information exchange in decentralized and distributed environments. The document describes a Web service. It specifies the location of the service and the operations (or methods) the service exposes. WSDL definition describes how to access a web service and what operations it will perform. WSDL is a language for describing how to interface with XML-based services. WSDL was developed jointly by Microsoft and IBM.

WSDL is often used in combination with SOAP and XML Schema to provide web services over the Internet. A client program connecting to a web service can read the WSDL to determine what functions are available on the server. Any special datatypes used are embedded in the WSDL file in the form of XML Schema. The client can then use SOAP to actually call one of the functions listed in the WSDL.

You can find more information about WSDL on following link.
http://www.tutorialspoint.com/wsdl/wsdl_introduction.htm

What you Required to Use KSOAP JAVA API.

To use KSOAP in your java application download the jar file from following link and add it on project class-path, so that you can use its api classes on your project or application.

http://ksoap2.sourceforge.net/

KSOAP Usage Example

In this Example I'm going to demonstrate how we can access a simple java web service using KSAOP Api.

Following is the sample java code for web service class. Deploy this web service on Tomcat server at local host.

Code

The WSDL file for above Web service Class will look like following

Code

Finally here it goes the use of KSOP Api classes to execute the webservice method “sayHello”.

Code

Code

Output :
output

Hope this example help you, For more information about KSOAP find following link.

http://ksoap2.sourceforge.net/
http://mspmsp.brinkster.net/MobileJava/ch16lev1sec3.htm
http://codeoncloud.blogspot.in/2012/04/android-web-service-access-tutorial.html http://codeoncloud.blogspot.in/2013/06/could-not-find-class.html


For further information, mail us at info@aegissoftwares.com