Query nfe in Java

Asked

Viewed 577 times

1

I want to make a form with the access key field and the code captcha to be filled in. This data will soon be sent to the NFE portal and will return the NFE information to me. The captcha I’ve already made it work on my form, I’m just not able to send this information.

The url is this: http://nfe.sefaz.ba.gov.br/servicos/nfenc/Modulos/Geral/NFENC_consulta_chave_acesso.aspx

Or this one too: https://www.nfe.fazenda.gov.br/portal/consulta.aspx?tipoConsulta=completa&tipoConteudo=XbSeqxE8pl8=

I think it would be something like:

DefaultHttpClient httpCliente = (DefaultHttpClient) request.getSession().getAttribute("httpClienteCnpj");

BasicClientCookie cookieFlag1 = new BasicClientCookie("flag","1");
cookieFlag1.setDomain("http://nfe.sefaz.ba.gov.br");

cookieFlag1.setPath("/");
httpCliente.getCookieStore().addCookie(cookieFlag1);

List<NameValuePair> lista = new ArrayList<NameValuePair>();

//teste
lista.add(new BasicNameValuePair("txt_cod_antirobo", receitaBean.getLetras()));
lista.add(new BasicNameValuePair("txt_chave_acesso", "43160988379771003017550010009335021009335027"));
lista.add(new BasicNameValuePair("btn_consulta_completa", "Consulta Completa"));

HttpPost post = new HttpPost("http://nfe.sefaz.ba.gov.br/servicos/nfenc/Modulos/Geral/NFENC_consulta_chave_acesso.aspx");
post.setEntity(new UrlEncodedFormEntity(lista));

HttpResponse response = httpCliente.execute(post);
No answers

Browser other questions tagged

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