Problems sending Nfe 4.0 to SP, MT and MS states

Asked

Viewed 63 times

0

I have problems sending the disabling of Nfe 4.0 only to the states of SP, MT and MS. The others are sending normally.

Is giving error in this part of the code:

HttpWebResponse responsePost = (HttpWebResponse)httpPostConsultaNFe.GetResponse();

Below is the sending code:

public string RequestWebService4_0(ConfiguracaoWebService configuracaoWebService, string param, string action, X509Certificate2 certificado, int tempoLimiteSefaz)
    {
        Uri urlpost = new Uri(configuracaoWebService.CaminhoServico);
        HttpWebRequest httpPostConsultaNFe = (HttpWebRequest)HttpWebRequest.Create(urlpost);

        string postConsultaComParametros = param;
        byte[] buffer2 = Encoding.ASCII.GetBytes(postConsultaComParametros);


        httpPostConsultaNFe.CookieContainer = cookies;
        tempoLimiteSefaz = tempoLimiteSefaz * 3000;
        httpPostConsultaNFe.Timeout = tempoLimiteSefaz;
        //httpPostConsultaNFe.ContentType = configuracaoWebService.ContentType;
        httpPostConsultaNFe.Headers.Add(@"SOAP:Action");
        httpPostConsultaNFe.ContentType = "text/xml;charset=\"utf-8\"";
        httpPostConsultaNFe.Accept = "text/xml";
        httpPostConsultaNFe.Method = "POST";
        httpPostConsultaNFe.ClientCertificates.Add(certificado);

        X509Certificate serverCert = X509Certificate.CreateFromCertFile(@"C:\PCInfo\certificado.pem");
        httpPostConsultaNFe.ClientCertificates.Add(serverCert);
        httpPostConsultaNFe.ServicePoint.Expect100Continue = true;
        httpPostConsultaNFe.ProtocolVersion = HttpVersion.Version11;
        httpPostConsultaNFe.AllowWriteStreamBuffering = true;


        //if (configuracaoWebService.CaminhoServico.Contains("Autorizacao4") || configuracaoWebService.CaminhoServico.Contains("autorizacao4"))
        httpPostConsultaNFe.Headers.Add("soapaction", action);

        //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
        //ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
        ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
        ServicePointManager.Expect100Continue = true;
        ServicePointManager.DefaultConnectionLimit = 9999;
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

        Stream PostData = httpPostConsultaNFe.GetRequestStream();
        PostData.Write(buffer2, 0, buffer2.Length);
        PostData.Close();

        HttpWebResponse responsePost = (HttpWebResponse)httpPostConsultaNFe.GetResponse();
        Stream istreamPost = responsePost.GetResponseStream();
        var strRespotaUrlConsultaNFe = new StreamReader(istreamPost, System.Text.Encoding.UTF8);

        return strRespotaUrlConsultaNFe.ReadToEnd();
    }
  • Paulo, I don’t know what your problem is, but I’ve already made the integration with a system that emits nfe, it’s developed in C# and has open source, see if it helps you with anything: http://www.unimake.com.br/uninfe/

  • I will look thank you very much Adriano

No answers

Browser other questions tagged

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