Object sent by Android arriving Null on Webservice server

Asked

Viewed 148 times

0

I’m creating an Android APP for college work, I’m using Android Studio and Eclipse Mars with Glassfish 4.

The webservice I believe is okay, because performing the requests by Soapui everything works fine, but when consuming with Android Studio, the object that arrives on the server is Null.

Follow the code used for Android called in Android Studio:

        public boolean inserirUsuario(Cliente cliente){

        SoapObject inserirUsuario = new SoapObject(NAMESPACE, INSERIR);

        SoapObject user = new SoapObject(NAMESPACE, "cliente");

        user.addProperty("id", cliente.getId());
        user.addProperty("cpf", cliente.getCpf());
        user.addProperty("primeiroNome", cliente.getPrimeiroNome());
        user.addProperty("sobrenome", cliente.getSobrenome());
        user.addProperty("email", cliente.getEmail());
        user.addProperty("senha", cliente.getSenha());
        user.addProperty("ddd", cliente.getDdd());
        user.addProperty("telefone", cliente.getTelefone());
        user.addProperty("ativo", cliente.isAtivo());

        inserirUsuario.addSoapObject(user);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

        envelope.setOutputSoapObject(inserirUsuario);

        envelope.implicitTypes = true;

        HttpTransportSE http = new HttpTransportSE(URL);

        try {
            http.call("\"urn:inserirUsuario\"", envelope);

            SoapPrimitive resposta = (SoapPrimitive) envelope.getResponse();

            return Boolean.parseBoolean(resposta.toString());
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

I tried to take out the "user" and send only the "insert User", but both ways the objects are arriving Null on the server.

Someone once had a similar problem and can help me with the solution?

2 answers

0

0

Make a request for your webservice using the Postman and see if the object will arrive null. If it arrives you will know that the problem is not at first on android.

Also try printing the object being sent to see if it is no longer empty at the beginning of the upload.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.