I have problems with an App in the Web Service that was consumed successfully. The detail was when security was added to the Web Service, for this a header was added.
Who can guide me what could be the detail? I seem to receive a response from the Web Service!
My asyntask:
public class WSLogin extends AsyncTask<String,String,String> {
//Aqui van mis variables string Namespacer etc etc etc///
String z = "";
Boolean isSuccess = false;
String user = edtuserid.getText().toString();
String pass = edtpass.getText().toString();
@Override
protected void onPreExecute() {
pbbar.setVisibility(View.VISIBLE);
}
@Override
protected void onPostExecute(String r) {
pbbar.setVisibility(View.GONE);
Toast.makeText(Login.this,r,Toast.LENGTH_SHORT).show();
if(isSuccess) {
Intent i = new Intent(Login.this,LibroCampo.class);
startActivity(i);
finish();
}
}
@Override
protected String doInBackground(String... params) {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME2);
request.addProperty("sID", user);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
Element[] headvalues = new Element[1];
headvalues[0] = new Element().createElement(NAMESPACE, tagCredecial);
Element tagUser = new Element().createElement(null, tagUSER);
tagUser.addChild(Node.TEXT, valUSER);
headvalues[0].addChild(Node.ELEMENT, tagUser);
Element tagPass = new Element().createElement(null, tagPASS);
tagPass.addChild(Node.TEXT, valPASS);
headvalues[0].addChild(Node.ELEMENT, tagPass);
envelope.headerOut = headvalues;
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
HttpTransportSE transporte = new HttpTransportSE(URL);
transporte.debug = true;
if(user.trim().equals("") || pass.trim().equals("")) {
z = "Usuario o Contraseña vacios";
} else {
try {
transporte.call(SOAP_ACTION2, envelope);
SoapObject result = (SoapObject)envelope.getResponse();
if ( user.equals(result.getProperty(0).toString()) && pass.equals(result.getProperty(2).toString())) {
z = "Bienvenido " + result.getProperty(1);
isSuccess=true;
SQLiteDatabase db = openOrCreateDatabase("SAICoffeeSQL", MODE_PRIVATE, null);
db.delete("tb_user_local",null, null);
ContentValues sEmp = new ContentValues();
sEmp.put("sIdUsuario", result.getProperty(0).toString());
sEmp.put("sUsuario", result.getProperty(1).toString());
sEmp.put("sPw", result.getProperty(2).toString());
sEmp.put("sIdAlmacen", Integer.valueOf(result.getProperty(3).toString()));
sEmp.put("bVerTodos", Boolean.valueOf(result.getProperty(4).toString()));
sEmp.put("bStatus", Boolean.valueOf(result.getProperty(5).toString()));
db.insert("tb_user_local",null, sEmp);
}else{
z = "Acceso denegado";
isSuccess=false;
}
} catch (Exception e) {
isSuccess = false;
z = "Acceso denegado" + e;
Log.i("", "" + e);
}
}
return z;
}
}
The error you dial:
SoapFault - faultcode: 'soap:Server' faultstring: 'El servidor no puede procesar la solicitud. ---> El mensaje de entrada no cumple el requisito R1012 de Simple SOAP Binding Profile 1.0.: UN MENSAJE DEBE serializar el sobre con codificación de caracteres UTF-8 o UTF-16.' faultactor: 'null' detail: org.kxml2.kdom.Node@6c112e8