• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps soap webservices in android login

krishnaveni

Well-Known Member
Dec 16, 2011
158
0
chennai
Hi.,

I have to develop an one android application.

Here I have to create the login page with mysql connection using soap webservices.

My code is working well on android 2.2 version.but its not working on android 4.0.

So here i have to use asynchronousTask .but now also am facing same problem.please check my code and give me the solutions.


i have following below code:

[HIGH]public class AndroidLoginExampleActivity extends Activity {
private final String NAMESPACE = "http://pricealert.com";
private final String URL = "http://192.168.2.102:8085/PriceAlert/services/Login?wsdl";
private final String SOAP_ACTION = "http://pricealert.com/authentication";
private final String METHOD_NAME = "authentication";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button login = (Button) findViewById(R.id.btn_login);
login.setOnClickListener(new View.OnClickListener() {

public void onClick(View arg0) {
new LongOperation().execute();

}
} );
}
class LongOperation extends AsyncTask<String, Void, String> {
private ProgressDialog Dialog = new ProgressDialog(LoginActivity.this);

@Override
protected String doInBackground(String... aurl) {
// TODO Auto-generated method stub
loginAction();
return null;
}

protected void onPreExecute() {
Dialog.setMessage("Loading...");
Dialog.show();
}

protected void onPostExecute(String resultGot) {
Dialog.dismiss();
}
}
private void loginAction(){
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

EditText userName = (EditText) findViewById(R.id.tf_userName);
String user_Name = userName.getText().toString();
EditText userPassword = (EditText) findViewById(R.id.tf_password);
String user_Password = userPassword.getText().toString();

//Pass value for userName variable of the web service
PropertyInfo unameProp =new PropertyInfo();
unameProp.setName("userName");//Define the variable name in the web service method
unameProp.setValue(user_Name);//set value for userName variable
unameProp.setType(String.class);//Define the type of the variable
request.addProperty(unameProp);//Pass properties to the variable

//Pass value for Password variable of the web service
PropertyInfo passwordProp =new PropertyInfo();
passwordProp.setName("password");
passwordProp.setValue(user_Password);
passwordProp.setType(String.class);
request.addProperty(passwordProp);

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

runOnUiThread(new Runnable() {
@Override
public void run() {
try{

androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();

TextView result = (TextView) findViewById(R.id.tv_status);
result.setText(response.toString());

}
catch(Exception e){

}
});
}

}[/HIGH]why am facing the above problems ??? please give me solution ??? How can i resolve these problems ???
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones