我正在使用php中的webservice开发一个android应用程序。 一切都工作到现在。 为了通信android和php我正在使用凌空库,一切正常但是这个。 我不知道它是否是这样一个最大数量的参数或什么。 一切都是真的, 我测试了一些东西,当我发送一半参数“工作”时,它返回错误500,但至少它发送了一些东西。 当我尝试发送所有参数时,会出现这个奇怪的错误。
这是我的代码,错误:
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);
}
错误:
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
答案 0 :(得分:3)
当任何参数值为null时,您将获得此异常。 检查参数中的值参数。