I'm using ksoap2 for web service method calls. First, the user must login. I want others method in web service could only be call after login. But i can not do that. Because I don't have any session in web service. I don't know how to do that in web service. How the web service know that user have already login in the android apps? Do you have any ideas, session or cookies :(. Thanks for reading my question. Here is my code in web service
public class Login {
String message;
Connection conn;
String url;
ResultSet rs;
Statement stmt;
public String login(String username, String password) {
try {
Class.forName("org.postgresql.Driver");
url = "jdbc:postgresql://localhost:5432/FirstDB";
conn = DriverManager.getConnection(
url, "postgres",
"root");
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * From account Where username = '"+ username + "'and password = '" + password +"'");
if ( rs.next() ) {
message = "true";
} else {
message = "false";
}
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}
return message;
}
public String Test() {
if(message.equals("true"))
{
return "abc";
}
return "bdf";
}
}
In the android app. First I call the method login(), then method Test(). The result always be "bdf".