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

Apps soap calling is not supported on my android real device

krishnaveni

Well-Known Member
Hi.,
i have developed one login form in android application calling mysql database calling soap webservices.it is worked successfully on android emulator.But not worked on android real device..please explain whats happened here.why my android real device is not supported soap calling.
package com.androidlogin.ws;

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



import android.preference.PreferenceManager;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.content.SharedPreferences;
import android.content.Context;
public class AndroidLoginExampleActivity extends Activity {
private static final String SPF_NAME = "vidslogin";
private static final String USERNAME = "username";
private static final String PASSWORD = "password";
private static final String PREFS_NAME = null;
CheckBox chkRememberMe;
private String username;
EditText userName,userPassword;
private final String NAMESPACE = "http://ws.userlogin.com";
private final String URL = "http://192.168.1.168:8085/Login/services/Login?wsdl";
private final String SOAP_ACTION = "http://ws.userlogin.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 register = (Button) findViewById(R.id.btn_reg);
register.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// Switching to Register screen
Intent i = new Intent(getApplicationContext(), RegisterActivity.class);
startActivity(i);
}
});
chkRememberMe = (CheckBox) findViewById(R.id.rempasswordcheckbox);
userName = (EditText) findViewById(R.id.tf_userName); // <--- Instantiate EditText...
userPassword = (EditText) findViewById(R.id.tf_password);
SharedPreferences loginPreferences = getSharedPreferences(SPF_NAME,
Context.MODE_PRIVATE);
userName.setText(loginPreferences.getString(USERNAME, ""));
userPassword.setText(loginPreferences.getString(PASSWORD, ""));

Button logout = (Button) findViewById(R.id.btn_logout);
logout.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = settings.edit();
editor.remove("username");

// Switching to Register screen
Intent i = new Intent(getApplicationContext(), AndroidLoginExampleActivity.class);
startActivity(i);
finish();
}
});

TextView forgetpassword = (TextView) findViewById(R.id.TextView03);
forgetpassword.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// Switching to Register screen
Intent i = new Intent(getApplicationContext(), ForgetPassword.class);
startActivity(i);
}
});
Button login = (Button) findViewById(R.id.btn_login);
login.setOnClickListener(new View.OnClickListener() {

public void onClick(View arg0) {
loginAction();

}
});
}


private void loginAction(){

boolean isUserValidated = true;
boolean isPasswordValidated = true;

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);

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

try{
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
String status = response.toString();
TextView result = (TextView) findViewById(R.id.tv_status);
result.setText(response.toString());

if(status.equals("Success!"))
{

// ADD to save and read next time
String strUserName = userName.getText().toString().trim();
String strPassword = userPassword.getText().toString().trim();
if (null == strUserName || strUserName.length() == 0)
{
// showToast("Enter Your Name");
userName.setError( "username is required!" );
isUserValidated = false;
}
if (null == strPassword || strPassword.length() == 0)
{
// showToast("Enter Your Password");
isPasswordValidated = false;
userPassword.setError( "password is required!" );
}
if(isUserValidated = true && isPasswordValidated == true)
{

if (chkRememberMe.isChecked())
{
SharedPreferences loginPreferences = getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
loginPreferences.edit().putString(USERNAME, strUserName).putString(PASSWORD, strPassword).commit();
} else
{
SharedPreferences loginPreferences = getSharedPreferences(SPF_NAME, Context.MODE_PRIVATE);
loginPreferences.edit().clear().commit();
}
}

if(isUserValidated && isPasswordValidated)
{


Intent intent = new Intent(AndroidLoginExampleActivity.this,HomePage.class);

intent.putExtra("username",userName.getText().toString());
startActivity(intent);

}
else
{
// what ever you want to do if the data in the EditText is not validated.
//Maybe restart the same intent ?
// Intent i = new Intent(getApplicationContext(), Login.class); startActivity(i);


}

}

else
{
Intent i = new Intent(getApplicationContext(), AndroidLoginExampleActivity.class);
startActivity(i);
}
}



catch(Exception e){

}
}

}

my logout window having:

displayed dis message on my logout window: 07-20 04:26:22.728: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by
protocol

In my device is displayed:below error is diplayed Java.net.SocketException:The operation timed out.

my emulator is 2.2.my android device version is 2.2.1.
 
I suggest to provide more details, log output, error messages etc if you expect any useful help.
 
I guess it can't reach the IP address. Make sure you are on the same network and the port is open.
 
it is successfully worked on my emulator.But it is not worked on android device.my ip address and port number all are correct only.
 
Back
Top Bottom