dimvisio / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

parse the soapobject #69

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.How to parse the soapobject responce
2.
3.

What is the expected output? What do you see instead?

package com.pxr.tutorial.soap.weather;

import java.util.ArrayList;
import java.util.Vector;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class Main<Pojo> extends Activity {

private static String SOAP_ACTION = "http://192.168.0.57/Get_All_Coaching_News";

    private static String NAMESPACE = "http://192.168.0.57/";
    private static String METHOD_NAME = "Get_All_Coaching_News";

    private static String URL = "http://192.168.0.57/LIJSL/LIJSLWebService.asmx";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //Initialize soap request + add parameters
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);

        // Make the soap call.
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        try {

            //this is the actual part that will call the webservice
            androidHttpTransport.call(SOAP_ACTION, envelope);        
        } catch (Exception e) {
            e.printStackTrace(); 
        }

        // Get the SoapResult from the envelope body.       
        SoapObject result = (SoapObject)envelope.bodyIn;

        if(result != null){
            TextView t = (TextView)this.findViewById(R.id.resultbox);
            t.setText("SOAP response:\n\n" + result.getProperty(0).toString());

        }

    }

}

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by vyas.dar...@gmail.com on 15 Jul 2011 at 9:16

GoogleCodeExporter commented 8 years ago
Done use bodyIn. Access the repsonse as SoapObject with getResponse() off 
envelope and then debug that as described on the wiki.

Original comment by mosa...@gmail.com on 18 Jul 2011 at 11:50

GoogleCodeExporter commented 8 years ago
Also .. just use getAttribute or getProperty on the soapObject... I am closing 
this as invalid since it is documented in various places.

Original comment by mosa...@gmail.com on 20 Jul 2011 at 5:45