i have a android application which needs username and password to login, i need to save the username and password in a remote server by entering the details in the register page with an alert box showing "Registerd successfully". when the user opens the app next time he will login . I want to use client/server mechanism, after I get the response I want to parse it either using sax parser or soap. I searched a lot through google but I didnt find correct example. As I am new to webservices I couldnt able to solve it, someone plz help me

EditText input1 = (EditText) findViewById(R.id.usertext);
EditText input2 = (EditText) findViewById(R.id.Passtext);
String username = input1.getText().toString();
String password = input2.getText().toString();

Thanks in advance.

link|flag

1 Answer

package com.google.android.Test;


import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransport;

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

public class myWebService extends Activity
{
         private static final String SOAP_ACTION = "HelloYou";
     private static final String METHOD_NAME = "getHello";
     private static final String NAMESPACE = "urn:HelloYou";
     private static final String URL = "http://localhost/lab/service.php";
     private Object resultRequestSOAP = null;

            @Override
            public void onCreate(Bundle icicle)
            {
                super.onCreate(icicle);
                TextView tv = new TextView(this);
                setContentView(tv);


            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);


             //SoapObject
            request.addProperty("firstname", "John");
            request.addProperty("lastname", "Williams");
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.setOutputSoapObject(request);


            HttpTransport androidHttpTransport = new HttpTransport(URL);
            try
            {
                androidHttpTransport.call(SOAP_ACTION, envelope);
                resultsRequestSOAP =  envelope.getResponse();
                String[] results = (String[])  resultsRequestSOAP;
                tv.setText( results[0]);
            }
            catch (Exception aE)
            {
                aE.printStackTrace ();;
            }
           }
}
link|flag

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.