calling webservices that return complexTypes in android using ksoap2

Ads
 

calling webservices that return complexTypes in android using ksoap2

Here's my code for android application,to call aweb service method and return a complexType object from it.

package com.example.gramaniladharidetails;

import java.util.Vector;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.Marshal;
import org.ksoap2.serialization.MarshalFloat;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

  public class GramaNiladhari extends Activity {
private static String SOAP_ACTION1= "http://localhost/getGramaNiladhariData";
private static String NAMESPACE = "http://119.235.4.217/";
private static String METHOD_NAME1 = "getGramaNiladhariData";
private static String URL = "";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_grama_niladhari);


    b.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {


            final String gndLifeCode = prov;
            String LifeCode = "3-2-09-060";
            request.addProperty("gndLifeCode", LifeCode);
            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);


            SupportThread st = new SupportThread();
            Log.i("Request", request.toString());
            st.execute(request);

        }
    });

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_grama_niladhari, menu);
    return true;
}

private class SupportThread extends
        AsyncTask<SoapObject, Object, SoapObject> {

    @Override
    protected SoapObject doInBackground(SoapObject... req) {
        SoapObject result = null;
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);

        envelope.setOutputSoapObject(req[0]);
        envelope.addMapping(NAMESPACE, "SerializeInfo",
                new SerializeInfo().getClass());

        Marshal floatMarshal = new MarshalFloat();
        floatMarshal.register(envelope);

        envelope.dotNet = true;

        try {
            envelope.encodingStyle = SoapSerializationEnvelope.XSD;
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

            androidHttpTransport.debug = true;

            androidHttpTransport.call(SOAP_ACTION1, envelope);
            SoapObject result = (SoapObject) envelope.getResponse();



            if (envelope.bodyIn instanceof SoapFault) {
                String str = ((SoapFault) envelope.bodyIn).faultstring;
                Log.i("*******", str);

            } else {
                int elementCount = result.getPropertyCount();

                if (elementCount > 0) {
                    String element;

                    for (int i = 0; i < elementCount; i++) {


                        element = result.getProperty(i).toString();
                        Log.d("This is an element", Integer.toString(i)
                                + " --" + element);


                    }
                }

            }

        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }

    @Override
    protected void onPostExecute(SoapObject result) {
        // TODO Auto-generated method stub
        super.onPostExecute(result);

        if (result != null) {
            String response_name = result.getName();

            TextView tv = (TextView) findViewById(R.id.textView5);
            tv.setText(result.getProperty(0).toString());
        }

        else {

            Toast.makeText(getApplicationContext(), "No Response",
                    Toast.LENGTH_LONG).show();

        } 
    }
}

}");

The webservice method i am calling retuns a complexType Object called GramaNiladhari. It consists of 5 string types. When I run this code I get the following SoapObject result.

anyType{gnName=anyType{}; address=anyType{}; workingDays=anyType{}; gnDivision=anyType{}; contactNumber=anyType{}; }

But here i am missing the values,and they are replaced with anyType{} . How can I retrieve the real values ?

View Answers

Ads









Related Tutorials/Questions & Answers:
calling webservices that return complexTypes in android using ksoap2
calling webservices that return complexTypes in android using ksoap2   Can anyone direct me to a site or show me an example ,on how to call a webservice which returns a complexType as the result, in an android app
calling webservices that return complexTypes in android using ksoap2
calling webservices that return complexTypes in android using ksoap2   Here's my code for android application,to call aweb service method and return..._niladhari, menu); return true; } private class SupportThread extends
Advertisements
webservices in websphere server using eclipse
webservices in websphere server using eclipse  can websphere server used instead of tomcat??...if so any changes to be made? Please elaborate
calling servlet from JS and return response from servlet to JS
calling servlet from JS and return response from servlet to JS  hello... page when user clicks on a button i am calling a javascript function(eg myFunc... task.now i want this servlet(myServlet) to return a url(eg. pages/file.jsp
Tictactoe game-2 players- using jax webservices & jsp
Tictactoe game-2 players- using jax webservices & jsp  Hi all, Could anyone please suggest the code /post source code of tictactoe game for 2 players with x & 0 as markers and use mysql database to persist the moves
webservices
webservices  can any one tell me how to develop and execute ---------- j2ee webservices example in weblogic server with (netbeans or eclipse
Webservices
Webservices  Hi, this is chinna, i am trying to develop a web service that has to return one table data. i have taken table data in a two dimensional...] + "DES" + projects[i][1]); } return projects
core java ,io operation,calling methods using switch cases
core java ,io operation,calling methods using switch cases  How to create a dictionary program,providing user inputs using io operations with switch cases and providing different options for searching,editing,storing meanings
Creating objects for classes and calling functions of a dll file using JNI
Creating objects for classes and calling functions of a dll file using JNI ... objects for these classes and how can we call these functions by using JNI. Am using myeclipse Please help me in resolving this problem. It?s urgent
WebServices In Java
WebServices In Java  Sample Example with screen shots using eclipse in java.it contain lower level to higher level example
Calling Methods Using SpEL
Calling Methods Using SpEL Spring 3 provides powerful Expression Language which can be used to wire values into beans properties by calling method of any... by calling methods. Person.java: The Person class contains property named "
webservices in java
webservices in java  what is the real time use of webservices in java
Android using database
Android using database  How to Add,delete,modify the contact name,address,phone no into the database using android coding
Calling Static Methods Using SpEL
Calling Static Method Using SpEL Spring 3 provides powerful Expression Language which can be used to wire values into beans properties by calling static method of any bean using SpEL's T() operator. Lets take an example
WebServices In Java
WebServices In Java  Need Web Services Examples in eclipse. Regards, Sathya
webservices security
webservices security  am doing project in web services security. can one sugesst me a best application for web service
video calling
video calling  how to implement video calling using java? i am a final year mca student please give me some samplecodes
video calling
video calling  how to implement video calling using java? i am a final year mca student please give me some samplecodes
WebServices In JAVA
WebServices In JAVA  need sample example for webservice in java platform(web application)   Hi, Please check Web Services Examples in NetBeans. Thanks
What is webservices?
What is webservices?  What is web-services and what are the different types of web-services? It would be great if someone explain me the difference between these types of web-services in Java
Sending data using bluetooth in android
Sending data using bluetooth in android  code to send data between two android mobile devices using bluetooth
ModuleNotFoundError: No module named 'webservices'
ModuleNotFoundError: No module named 'webservices'  Hi, My Python... 'webservices' How to remove the ModuleNotFoundError: No module named 'webservices' error? Thanks   Hi, In your python environment
What is SOA and Webservices?
What is SOA and Webservices?  Hi, I want to learn SOA and Webservices. Can anyone tell me What is SOA and Webservices? Thanks   Hello, Check the tutorial: SOA and Web Services Thanks
Calling Destructor
Calling Destructor  How can i call destructor in java using System.gc() or manually. Please anyone give me a example program   Java... to the file."); } } Java Garbage Collection using System.gc
webservices adding in eclipse
webservices adding in eclipse  hi team, i am working on webservices, please guide me how to add webservices in eclispe with step by step and give...://www.roseindia.net/webservices/buildingsimplewebservice.shtml
writing webservices in php
writing webservices in php  How to write a simple web service in PHP
WebServices Study Material
WebServices Study Material  Hello, I want deatail study material with program examples, is this possible to mail me
Calling a function
Calling a function  Hi, I have a function xyz() in php code. When a button is clicked it should execute that particular function for that i have written as <form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
Version of geronimo>geronimo-webservices dependency
List of Version of geronimo>geronimo-webservices dependency
ModuleNotFoundError: No module named 'chembl_webservices'
ModuleNotFoundError: No module named 'chembl_webservices'  Hi, My... named 'chembl_webservices' How to remove the ModuleNotFoundError: No module named 'chembl_webservices' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'tornado-webservices'
ModuleNotFoundError: No module named 'tornado-webservices'  Hi, My... named 'tornado-webservices' How to remove the ModuleNotFoundError: No module named 'tornado-webservices' error? Thanks   Hi

Ads