Print Friendly, PDF & Email

This article will help you call a SOAP web service in the simplest way. We will pass a parameter to the web service and will receive the 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 have to 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″ />

  •  
  •  
  •  
  •  
  •  
Previous articleWeb Scraping is Dynamic
Next articleData Mining and Databases Technology-A Bias in Biopharmaceutical Industry
Welcome to Loginworks! Our team of technical writers works extensively to share their knowledge with the outer world. Our professional writers deliver first-class business communication and technical writing to go extra mile for their readers. We believe great writing and knowledge sharing is essential for growth of every business. Thus, we timely publish blogs on the new technologies, their related problems, their solutions, reviews, comparison, and pricing. This helps our readers to get the better understanding of the technologies and their benefits. For the everyday updates on technologies keep visiting to our blog.

LEAVE A REPLY

Please enter your comment!
Please enter your name here