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?
– Jéf Bueno
@LINQ, yes I have, bought just to do the tests!
– Alexandre Neukirchen
What appears when you try to access the page through the browser?
– Jéf Bueno
which page? this: https://nfe-homologacao.sefazrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao.asmx, if yes, two methods appear
nfeAutorizacaoLote
andnfeAutorizacaoLoteZip
– Alexandre Neukirchen