Android kSoap2 web service parsing Data.

Thursday, September 27, 2012

Android kSoap2 web service Parsing Data
In this tutorial for Android ksoap2 web service . we can passing data through web service and store the data in web server.
how to read and parse JSON or XML, but another (pretty big) format is SOAP. In this post we will see how you make a application that reads and parses SOAP data into a Android application!
first we need ksoap2-android-assembly-2.5.6-jar file. download this jar file and put your workspace lib folder.

  • Just click the most recent version
  • search for the jar file with dependencies.
  • download it by right clicking the link "Raw file"
  • then clicking "Save as ...".
  • Save it inside your project folder so you can link it easily. 
Note: add the jar file to the project. ( Project properties -> Java build path -> Add JAR's )

Source code :

package com.soap;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;
public class Mainactivity extends Activity {
    ImageButton b;
    private final String NAMESPACE = "http"//";
    private final String METHOD_NAME = "InsertChild";
    private final String SOAP_ACTION = "";
    private final String URL = "";
   // protected static final String END_DOCUMENT =null;
    public void onCreate(Bundle savedInstanceState) {
                 //   SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
                 ///  request.addProperty("ChildName","jay");
                   SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
                    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    envelope.setOutputSoapObject(request);                                 .
                    HttpTransportSE  httpTransport = new HttpTransportSE(URL);
                    httpTransport.debug = true;
                    try {
           , envelope);
                     SoapObject result = (SoapObject) envelope.bodyIn;
                           Log.i("Result", result.toString());
                    } catch (IOException e) {
                     // TODO Auto-generated catch block
                    } catch (XmlPullParserException e) {
                     // TODO Auto-generated catch block
                    } // This sends a soap
                   Log.i(envelope.bodyIn.toString()," ");


Post a Comment

Note: Only a member of this blog may post a comment.