NF-e query with response: "Paralyzed Service without Prediction"

4

I'm doing in a project a module of search and XML download of NF-e next to SEFAZ.

I made all the settings and pointed the requests to the WebService informed on the recipe site but it is returning the following error:

<retDownloadNFe versao="1.00" xmlns="http://www.portalfiscal.inf.br/nfe">
    <tpAmb>1</tpAmb>
    <verAplic>AN.DownNF_2.1.1</verAplic>
    <cStat>109</cStat>
    <xMotivo>Servico Paralisado sem Previsao</xMotivo>
    <dhResp>2017-08-15T09:58:12</dhResp>
</retDownloadNFe>

Does anyone have any idea what it can be?

    
asked by anonymous 15.08.2017 / 15:23

1 answer

3

The webservice DownloadNFe has been deactivated according to NT 2014.002.v.1.02.

The webservice you should use is:

https://www1.nfe.fazenda.gov.br/NFeDistribuicaoDFe/NFeDistribuicaoDFe.asmx

In this webservice you make the manifestation of the recipient and in the next query it returns the complete NFe XML.

Follow the link of the technical note: Technical Note 2014.002 - v1.02

I made a very simple example, I put a button and a textbox in a form. I added the webservice address in the visual studio project as ServiceReference, so visual studio already generates the necessary classes. Here is the code:

Do not forget to replace the code data with your company data, and without reading the technical note you can not understand the return of the webservice.

    private void button1_Click(object sender, EventArgs e)
    {
        NFeDistribuicaoDFeSoapClient consDFe = new NFeDistribuicaoDFeSoapClient();

        consDFe.ClientCredentials.ClientCertificate.Certificate = ObterDoRepositorio();
        distDFeInt distDfe = new distDFeInt();
        distDfe.versao = TVerDistDFe.Item100;
        distDfe.tpAmb = TAmb.Item1;
        distDfe.cUFAutor = TCodUfIBGE.Item50;
        distDfe.ItemElementName = ItemChoiceType.CNPJ;
        distDfe.Item = "000000000000000";
        distDFeIntDistNSU distNSU = new distDFeIntDistNSU();
        distNSU.ultNSU = "000000000";
        distDfe.Item1 = distNSU;
        string xmlEnvio = SerializeToString(distDfe);
        var removeq1 = new string[] { ":q1", "q1:" };
        foreach (var item in removeq1)
        {
            xmlEnvio = xmlEnvio.Replace(item, string.Empty);
        }
        XElement xml = XElement.Parse(xmlEnvio);
        var asd = consDFe.nfeDistDFeInteresse(xml);
        textBox1.Text = asd.ToString();


    }

    public static X509Certificate2 ObterDoRepositorio()
    {
        var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
        store.Open(OpenFlags.OpenExistingOnly | OpenFlags.MaxAllowed);

        var collection = store.Certificates;
        var fcollection = collection.Find(X509FindType.FindByTimeValid, DateTime.Now, true);
        var scollection = X509Certificate2UI.SelectFromCollection(fcollection, "Certificados válidos:", "Selecione o certificado que deseja usar",
            X509SelectionFlag.SingleSelection);

        if (scollection.Count == 0)
        {
            throw new Exception("Nenhum certificado foi selecionado!");
        }

        store.Close();
        return scollection[0];
    }

    public static string SerializeToString(Object value)
    {
        var emptyNamepsaces = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty });
        var serializer = new XmlSerializer(value.GetType());
        var settings = new XmlWriterSettings();
        settings.OmitXmlDeclaration = true;

        using (var stream = new StringWriter())
        using (var writer = XmlWriter.Create(stream, settings))
        {
            serializer.Serialize(writer, value, emptyNamepsaces);
            return stream.ToString();
        }
    }

Link in github

    
15.08.2017 / 16:51