我正在使用肥皂方法发送请求。然后我将响应存储在 doInBackground 中的 String 变量中,然后检查条件 onPostExecute。但是当我一步一步检查它时,我知道它正在清除 onPostExecute 的值。如何解决这个问题?
protected Void doInBackground(Void... args) {
request = new SoapObject(NAMESPACE, METHOD_NAME);
username = new PropertyInfo();
username.setName("UserName");
username.setValue(Username);
username.setType(String.class);
request.addProperty(username);
password = new PropertyInfo();
password.setName("Password");
password.setValue(Password);
password.setType(String.class);
request.addProperty(password);
SoapSerializationEnvelope envp = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envp.dotNet = true;
envp.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envp);
SoapPrimitive response = (SoapPrimitive) envp.getResponse();
Response = response.toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
if (dialog != null) {
dialog.dismiss();
dialog = null;
}
if (Response.equals("Fail")) {
etPassword.setText("");
textValidation.setText("UserName Or Password is Wrong.");
} else {
etUsername.setText("");
etPassword.setText("");
}
}