我开发了登录表单android应用程序。在这里,我必须实现忘记密码字段。如果我点击那个忘记密码,textview
那么它将进入下一个活动。
下一个活动将接收用户的电子邮件,并从调用 soap 的 mysql 数据库检查其验证webservices
。
我已经完成了上述部分。
现在我必须实现以下部分:
电子邮件有效意味着从 mysql 数据库中获取密码并将这些密码发送到有效的电子邮件。
如何在我的 java webservice 代码中实现这部分。请帮助我。给我一些解决方案。
这是我用于检查电子邮件有效或无效的 java webservice 代码:
public class Checkemail {
public String authentication(String Email){
String retrievedUserName = "";
String status = "";
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/xcart-432pro","root","");
PreparedStatement statement = con.prepareStatement("SELECT * FROM xcart_customers WHERE email = '"+Email+"'");
ResultSet result = statement.executeQuery();
while(result.next()){
retrievedUserName = result.getString("email");
}
if(retrievedUserName.equals(Email)){
status = "Valid Email";
}
else{
status = "Invalid Email!!!";
}
}
catch(Exception e){
e.printStackTrace();
}
return status;
}
}
这是我的安卓代码:
public class Login extends Activity {
private final String NAMESPACE = "http://xcart.com";
private final String URL = "http://10.0.0.75:8080/XcartLogin/services/Checkemail?wsdl";
private final String SOAP_ACTION = "http://xcart.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.login);
Button login = (Button) findViewById(R.id.btn_login);
login.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
loginAction();
}
});
}
private void loginAction(){
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
EditText Email = (EditText) findViewById(R.id.tf_userName);
String email = Email.getText().toString();
//Pass value for userName variable of the web service
PropertyInfo unameProp =new PropertyInfo();
unameProp.setName("Email");//Define the variable name in the web service method
unameProp.setValue(email);//set value for userName variable
unameProp.setType(String.class);//Define the type of the variable
request.addProperty(unameProp);//Pass properties to the variable
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());
}
catch(Exception e){
}
}
}
如何在 java webservice 代码中实现获取密码发送到电子邮件?