alamein72 / ksoap2-android

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

Parsing xml using ksoap #170

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
i have used Ksoap2 to connect to this .NET web service and i get a xml response 
when i enter the users id, i only want to see two tags callTitle and 
callDescription i dont need the rest and i want to see in text not surround 
with xml code can some please help i cant find no tutorial online  

package com.sencide;

import java.io.IOException;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.Marshal;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class AndroidWebService extends Activity {

    /** Called when the activity is first created. */
    private static String SOAP_ACTION = "http://tempuri.org/GetHelpDeskCalls";
    private static String NAMESPACE = "http://tempuri.org/";
    private static String METHOD_NAME = "GetHelpDeskCalls";
    static final String URL = "https:/192.2344.123:8080/Service1.asmx";

    Button getData;
    EditText userID;
    TextView data;

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

        getData = (Button) findViewById(R.id.button1);
        userID = (EditText) findViewById(R.id.txtFar);
        data = (TextView) findViewById(R.id.textView1);

        Thread nT = new Thread() {
            @Override
            public void run() {

                getData.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {

                        SoapObject request = new SoapObject(NAMESPACE,
                                METHOD_NAME);

                        request.addProperty("userID", userID.getText()
                                .toString());

                        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                                SoapEnvelope.VER11);

                        envelope.setOutputSoapObject(request);
                        envelope.dotNet = true;
                        HttpTransportSE androidHttpTransport = new HttpTransportSE(
                                URL);

                        try {

                            androidHttpTransport.debug = true;
                            androidHttpTransport.call(SOAP_ACTION, envelope);

                            final String results = androidHttpTransport.responseDump
                                    .toString();

                            runOnUiThread(new Runnable() {
                                public void run() {

                                    data.setText(results.toString());
                                }

                            });

                        } catch (Exception e) {

                            data.setText("Error" + e);

                        }

                    }

                });

            }

        };
        nT.start();
    }

}

Original issue reported on code.google.com by rafaelma...@gmail.com on 2 Aug 2013 at 3:21

Attachments:

GoogleCodeExporter commented 8 years ago
Dont use bugs for requesting help.

Original comment by mosa...@gmail.com on 15 Oct 2013 at 3:52