Error while sending Nfe

Asked

Viewed 614 times

1

I’m trying to send Nfe using the SEFAZ RS webservice, but this generating some errors when I call the method nfeAutorizacaoLote. It seems that the error is in the configuration of the webservice.

When referring to URL by Visual Studio, the following configuration is created in the file web.config:

<system.serviceModel>
    <client>
        <endpoint address="https://nfe-homologacao.sefazrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao.asmx" 
        binding="basicHttpBinding" 
        bindingConfiguration="NfeAutorizacaoSoap" 
        contract="NFeAutorizacao.NfeAutorizacaoSoap" 
        name="NfeAutorizacaoSoap" />
    </client>
    <bindings>
        <basicHttpBinding>
            <binding name="NfeAutorizacaoSoap">
                <security mode="Transport" />
            </binding>
            <binding name="NfeAutorizacaoSoap1" />
        </basicHttpBinding>
    </bindings>
</system.serviceModel>

However you are returning the error below, I will call erro1:

The HTTP request is prohibited with the client authentication scheme 'Anonymous'

From what I’ve researched, one of the possibilities would be to change the configuration of:
<security mode="Transport" />
for:
<security mode="TransportCredentialOnly"/>


However, just returned another error, I’ll call erro2:

The https provider’s URI scheme is invalid; expected http. r nName of parameter: via

I have tested all possible settings for mode, and always returns or the erro1 or the erro2. I performed a parallel test by validation service XML and everything is all right with the file, the problem is in the request of the webservice.

Here is the snippet of the code that makes the request:

try
{
    XmlDocument oXmlDoc = new XmlDocument();
    oXmlDoc.Load("c:\teste.xml");
    XmlNode oNode = oXmlDoc.DocumentElement;
    NFeAutorizacao.NfeAutorizacaoSoapClient oNfeAutorizacaoSoapClient = new NFeAutorizacao.NfeAutorizacaoSoapClient();
    NFeAutorizacao.nfeCabecMsg onfeCabecMsg = new NFeAutorizacao.nfeCabecMsg();
    onfeCabecMsg.versaoDados = "3.10";
    onfeCabecMsg.cUF = "43";
    XmlNode xmlnode = oNfeAutorizacaoSoapClient.nfeAutorizacaoLote(ref onfeCabecMsg, oNode);
}
catch (Exception exc)
{

}

Obs: When accessing the URL, it is necessary to have a digital certificate, otherwise it will return prohibited access: HTTP Error 403.7 - Forbidden: The page you are attempting to access requires your browser to have a Secure Sockets Layer (SSL) client certificate that the Web server recognizes.

  • You have a valid certificate installed on the machine?

  • @LINQ, yes I have, bought just to do the tests!

  • What appears when you try to access the page through the browser?

  • which page? this: https://nfe-homologacao.sefazrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao.asmx, if yes, two methods appear nfeAutorizacaoLote and nfeAutorizacaoLoteZip

1 answer

2


I did not do with authorization but it is so my used Nfedistribução and event reception below configuration of webconfig:

 <binding name="RecepcaoEventoSoap">
    <security mode="Transport">
        <transport clientCredentialType="Certificate" proxyCredentialType="None"/>
    </security>
 </binding>
  • Good morning Eduardo, you even developed the Donwload of the xmls issued against the cnpj?

  • I did get through the Nfedistribução which doubt would be?

  • Good Afternoon Eduardo, I also managed, if you want to take a look at this link: https://github.com/thgmbz/DownloadXML-NT2014.002 I made some changes to improve the code but this project is still the first one works perfectly. Thank you

  • @Thiagomottabarboza was nice to follow her on github

Browser other questions tagged

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