Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa WebSevices calling webservices that return complexTypes in android using ksoap2
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


uthpala
calling webservices that return complexTypes in android using ksoap2
0 Answer(s)      2 years and a month ago
Posted in : WebSevices


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 ?


Advertisement
View Answers

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
Android using database
Android using database  How to Add,delete,modify the contact name,address,phone no into the database using android coding
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
Sending data using bluetooth in android
Sending data using bluetooth in android  code to send data between two android mobile devices using bluetooth
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
webservices
webservices  can any one tell me how to develop and execute ---------- j2ee webservices example in weblogic server with (netbeans or eclipse
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  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
Android
Android  How to create Android sample program
android
android  wat are the basic language need to develope android os
android
android  Is it possible to have an android mobile without operating system ? Is it possible to format the android mobile and make it without operating system
ANDROID
ANDROID   Hi Frds, I developed android app which access the external memory(MicroSD) data,It works in android mobile (Samsung Galaxy Y),But it not works in Samsung Tab 2.It shows some exception like Android :: Out
Android
Android  how to read input values from a dialog box to hash table and put those values to another dialog box in android
What is Android Application Framework?
applications on Android operating environment using the java programming language... programming language using the tools and API libraries provided by Android SDK... android which for some time in the common people's perception has almost become
how to scroll multiple images using on Click in Android
how to scroll multiple images using on Click in Android  I am new android platform, now i am working with small application. here there is requirement like multiple image scrolling dynamically. But unfortunately i am unable
WebServices In Java
WebServices In Java  Sample Example with screen shots using eclipse in java.it contain lower level to higher level example
Android Studio Training
for the developing applications using Android SDK. The Android Studio is based... discussed here is developed using the Android Studio Development IDE. Here...Android Studio Training Videos and examples Here we are giving complete
Webservices - WebSevices
Webservices  Hi All, Can anybody send me the sample application for developing webservices using axis2 with Eclipse Plugin. Thanks. regards anwar
problen in displaying the text and image in gallery using Android
problen in displaying the text and image in gallery using Android   public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); gallery = (Gallery
webservices - WebSevices
webservices i find that there are number of ways to develop webservices which one is good... me one simple webservice application using axis2 as soon as possible. Thanks.... http://www.roseindia.net/webservices/web-services-development.shtml Thanks
webservices in java
webservices in java  what is the real time use of webservices in java
calling a session bean bean from servlet using netbeans - EJB
calling a session bean from servlet using netbeans  How to call a session bean from servlet using netbeans in Java
webservices - WebSevices
webservices  i want a sample on webservices which can help me to build a custom webservice project using GlassFish 2 ? NetBeans 6.1 ? SSH... reservation using webservises
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
WebServices In Java
WebServices In Java  Need Web Services Examples in eclipse. Regards, Sathya
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
Google Android Emulator
Google Android Emulator       If you want to test, run and debug your Android apps without using a physical Android based mobile then you just need the Android Emulator
Non SOAP webservices - WebSevices
webservices in WebLogic? i believe we can do using REST however is there any other option other than REST to implement non-soap webservices? Do we have WSDL incase of non-soap webservices
webservices security
webservices security  am doing project in web services security. can one sugesst me a best application for web service
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
Advertisements
 

 

 

DMCA.com