India Flag: +91.120.4251349/34
USA Flag : +1 (804) 591-0052
Logo

LW Employees

Working With SOAP Web Service Through Android

Amit

Working With SOAP Web Service Through Android

Posted in technical blogs

This article will help you call a SOAP web service in the simplest way. We will pass a parameter to the web service an will receive it’s result. In this tutorial I have used w3school’s TempConvert web service. It’s publicly available to everyone to consume the web service.

 

Before we begin with the code, we would to have download KSOAP library for our android project. The library used in this article is ksoap2-android-assembly-2.6.1-jar-with-dependencies.jar. To include this library in your project – Right Click on the project> Select Properties> Java Build Path> Libraries Tab> Add External JARs and then select your downloaded library. Now, on the Order and Export Tab checkmark the checkbox for this library.

 

The web service has two methods i.e CelsiusToFahrenheit and FahrenheitToCelsius so we have to design a simple android activity for the same.

Layout – main.xml

android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:orientation=”vertical” >

<TextView
android:id=”@+id/textView1″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”TempConvert”
android:layout_gravity=”center”
android:layout_marginBottom=”20dp”
android:textAppearance=”?android:attr/textAppearanceLarge” />

<TextView
android:id=”@+id/textView2″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Input:” />

<EditText
android:id=”@+id/editText1″
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:inputType=”text”
android:layout_marginBottom=”5dp”
android:ems=”10″ >

 

<TextView
android:id=”@+id/textView3″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Convert To:” />

android:layout_width=”wrap_content”
android:layout_height=”wrap_content”>

<RadioButton
android:id=”@+id/radioButton1″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Celsius” />

<RadioButton
android:id=”@+id/radioButton2″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginBottom=”5dp”
android:text=”Fahrenheit” />

 

<TextView
android:id=”@+id/textView4″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Result:” />

<EditText
android:id=”@+id/editText2″
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:inputType=”text”
android:editable=”false”
android:ems=”10″ />

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Shares