Good morning
I am already in the final stages of the development of the app in android studio, only now I find myself in doubt, what happens is that when I run my webservices and send data to be recorded in my system but it returns me an error, that's where I'm confused, because I'm doing a validation with a IF
that if it comes back to me ok the webservices send me a message Toast
that the data was saved, and in the else an error message , but when I click on the save button it does not show me my error message,
I leave my code to see if I'm doing my validation well.
Method Record data, in the return Result returns me the answer my webservices of the error, that error is the one that I want to show a Toast
public static String GrabarCxCP(int Recurso,
int Modulo,
int Operacion,
int Documento,
int OrigenId,
int OrigenDocumento)
{
String resultado = "";
SoapObject request = new SoapObject("http://oncontrol.no-ip.net:9020/", "GrabarCXCP");
request.addProperty("Recurso", Recurso);
request.addProperty("Modulo", Modulo);
request.addProperty("Operacion", Operacion);
request.addProperty("Documento", Documento);
request.addProperty("OrigenId", OrigenId);
request.addProperty("OrigenDocumento", OrigenDocumento);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.implicitTypes = false;
// Set output SOAP object
envelope.setOutputSoapObject(request);
// Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL, 7000);
try {
androidHttpTransport.debug = true;
// Invoke web service
androidHttpTransport.call("http://oncontrol.no-ip.net:9020/GrabarCXCP", envelope);
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
resultado=response.toString();
} catch (Exception e) {
//Assign Error Status true in static variable 'errored'
e.printStackTrace();
}
return resultado;
}
The OnPostExecute
method makes my if
to show me the messages either error or it ran correctly:
@Override
protected void onPostExecute(String Resultado) {
super.onPostExecute(Resultado);
if ((Resultado.equals("OK")))
{
Toast.makeText(getApplicationContext(), "Datos Guardado Correctamen", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(getApplicationContext(), "Error en el Wbservices", Toast.LENGTH_SHORT).show();
}
}