Soap: Header ... problems


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();

    protected void onPreExecute() {

    protected void onPostExecute(String r) {
        if(isSuccess) {
            Intent i = new Intent(Login.this,LibroCampo.class);

    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.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 {
      , envelope);
                SoapObject result = (SoapObject)envelope.getResponse();

                if ( user.equals(result.getProperty(0).toString()) &&  pass.equals(result.getProperty(2).toString())) {
                    z = "Bienvenido " + result.getProperty(1);
                    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);
                    z = "Acceso denegado";
            } 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: [email protected]
asked by Mark Dev 21.06.2016 в 18:02

2 answers


Good friends after hours and days of giving me the solutions was so simple that better as they say here in my town or cry is good ... but there goes the answer:

The problem was that the SoapSerializationEnvelope object did not add the UTF-8 charset, and I put the solution to help them in their projects and applications, in good time:

  • First of all the dependency of Ksoap2-android-assambly-3.4.0-jar-whith-dependencies, is what worked for me, since I was using an earlier version that did not support the option I wanted; I'll explain in the following points, how to correctly construct the objects and how to fill the function correctly.
  • If you see this answer you have already realized how to build or assemble the SoapSerializationEnvelope object which is responsible for creating the structure of the request and the class that is responsible for creating it, with their respective configuration options:

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope.VER11);         envelope.setOutputSoapObject (request);         envelope.implicitTypes = true;         envelope.setAddAdornments (false);         envelope.dotNet = true;         envelope.headerOut = header;


  • In addition to this structure, other values are added that identify the type of document, the shipping method, the CHARTSET (this is a parameter that mediates several headaches), in theory (I do not know much about Android, I have only spent two months developing on this platform) classes (parents and children) that are responsible for that is I put the code:

    HttpTransportSE transport = new HttpTransportSE (URL);

  • Up to this point everything worked correctly, this part is optional (unless you handle more security when making requests to the Web Service) in my case, I add the following code and the parameter that I need to add:

    List headerPropertieList = new ArrayList ();  headerPropertieList.add (new HeaderProperty ("Content-Type", "text / xml; charset = utf-8"));

  • to then use it in the HttpTransportSE object call method, and it looks like this: (SOAP_ACTION, envelope, headerPropertieList); /// all your code or methods or classes in order everything you can think of: D

  • And Presto everything works (at least for me successfully).

  • I hope it helps, I do not know everything, but we are in the process of learning this was my experience

    answered by 25.06.2016 в 01:19

    According to your error message:


    The input message does not meet the R1012 requirement of Simple SOAP   Binding Profile 1.0 .: A MESSAGE MUST serialize the envelope with   UTF-8 or UTF-16 character encoding. '

    add the encodingStyle = "UTF-8" property to your request:

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.encodingStyle = "UTF-8";
    answered by 21.06.2016 в 18:33