1

I'm developing an android aplication using a webservice in php. Everything was working until now. To comunicate android and php I'm using the volley library, and everything is working but this. I don't know if it is something such a maximum number of parameters or what. Anything is truly null, I've test something, when I send half the parameters it "works", it returns me error 500, but at least it sends something. When I try to send all the parameters, this weird error shows up.

here is my code, and the error:

public void inserePagamento(final Context ctx, DocTed docTed,
        final ProgressDialog ringProgressDialog) {

    String url = "http://192.168.1.168/declabank/ws/public/transacaoDocTed";
    Encriptador cesar = Encriptador.getInstance();
    HashMap<String, String> params = new HashMap<String, String>();
    params.put("agencia", usuario.getAgencia());
    params.put("conta", usuario.getConta());
    params.put("cripto",cesar.encriptar(cesar.getChave(), usuario.getNome()));

    params.put("docFavorecidoNome", docTed.getNomeFav());
    params.put("docFavorecidoCompensacao", docTed.getCodComp());
    params.put("docFavorecidoBanco", docTed.getCodBanco());
    params.put("docFavorecidoAgencia", docTed.getnAgencia());
    params.put("docFavorecidoConta", docTed.getnConta());
    params.put("docFavorecidoCPFCNPJ", docTed.getCpfCnpj());
    params.put("docFavorecidoTipo", docTed.getDocFTipo());
    params.put("docTed", "" + docTed.getDocTed());
    params.put("docFinalidadeTransacao", docTed.getFinalidadeCod());
    params.put("docTitularidade", docTed.getTipoDoc());
    params.put("docValor", docTed.getValor());
    params.put("docData", docTed.getData());
    params.put("docRemetenteNome", docTed.getNomeRemetente());
    params.put("docRemetenteCPFCNPJ", docTed.getCpfCnpjRemetente());
    params.put("docRemetenteConta", docTed.getContaRemetente());
    params.put("CXC_COD_CX", docTed.getCodCx());
    params.put("docOrigem", docTed.getOrigem());
    params.put("docStatus", "" + docTed.getStatus());
    params.put("docComprovante", docTed.getComprovante());
    params.put("docTransferirEm", docTed.getTransferirEm());
    params.put("docAgendado", "" + docTed.getAgendado());

    RequestQueue rq = Volley.newRequestQueue(ctx);

    DeclaJSONArrayRequest djson = new DeclaJSONArrayRequest(Method.POST,
            url, params, new Response.Listener<JSONArray>() {
                @Override
                public void onResponse(JSONArray responseArray) {
                    try {
                        JSONObject response = responseArray
                                .getJSONObject(0);
                        try {
                            Log.e("DocTed", "DocTed gravado");
                            Log.e("DocTed", "DocTed gravado");
                            Log.e("DocTed", "DocTed gravado");
                            Log.e("DocTed", "DocTed gravado");
                            Log.e("DocTed", "DocTed gravado");
                            String erro = response.getString("erro");
                            ringProgressDialog.dismiss();
                            Toast.makeText(ctx, erro, Toast.LENGTH_LONG)
                                    .show();

                        } catch (JSONException e) {
                            e.printStackTrace();

                        }
                    } catch (JSONException e) {

                        e.printStackTrace();
                    }

                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    if (error != null) {
                        Toast.makeText(ctx, "Erro: ", Toast.LENGTH_LONG)
                                .show();
                        Log.e("Erro", "" + error.getMessage());

                    } else {
                        Toast.makeText(ctx, "Erro: " + error.getMessage(),
                                Toast.LENGTH_LONG).show();
                        Log.e("Erro", "Treta da Grossa");

                    }

                }
            });
    djson.setTag("TagPagamento");
    djson.setRetryPolicy((RetryPolicy) new DefaultRetryPolicy(15000,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    rq.add(djson);

}

error:

  11-25 11:46:17.556: E/Volley(4874): [404] NetworkDispatcher.run: Unhandled exception     java.lang.NullPointerException
    11-25 11:46:17.556: E/Volley(4874): java.lang.NullPointerException
    11-25 11:46:17.556: E/Volley(4874):     at libcore.net.UriCodec.encode(UriCodec.java:132)
    11-25 11:46:17.556: E/Volley(4874):     at java.net.URLEncoder.encode(URLEncoder.java:57)
    11-25 11:46:17.556: E/Volley(4874):     at com.android.volley.Request.encodeParameters(Request.java:463)
    11-25 11:46:17.556: E/Volley(4874):     at com.android.volley.Request.getBody(Request.java:449)
    11-25 11:46:17.556: E/Volley(4874):     at com.android.volley.toolbox.HurlStack.addBodyIfExists(HurlStack.java:236)
    11-25 11:46:17.556: E/Volley(4874):     at com.android.volley.toolbox.HurlStack.setConnectionParametersForRequest(HurlStack.java:210)
    11-25 11:46:17.556: E/Volley(4874):     at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:106)
    11-25 11:46:17.556: E/Volley(4874):     at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:96)
    11-25 11:46:17.556: E/Volley(4874):     at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:110)
    11-25 11:46:21.496: E/Erro(4874): java.lang.NullPointerException
Tomislav Novoselec
  • 4,570
  • 2
  • 27
  • 22
Cristiano Guerra
  • 615
  • 1
  • 7
  • 12

1 Answers1

3

you will get this exception, when the any of the params value is null. Check your value parameters in params.

Satya Attili
  • 678
  • 1
  • 8
  • 17