2
I am trying to perform the service status query for Nfe 3.10 but always is returning the following message:
The HTTP request is prohibited with the authentication scheme client 'Anonymous'.
I’m using Visual Studio 2012 and . NET Framework 4.5.
I’m using the code below, would someone let me know if something is missing?
String caminho = "C:\\Arquivos\\Upload\\certificado.pfx";
String senha = "123456789";
X509Certificate2 certificado = new X509Certificate2(caminho, senha);
TConsStatServ statusServer = new TConsStatServ();
statusServer.versao = "3.10";
statusServer.tpAmb = TAmb.Item2;
statusServer.cUF = TCodUfIBGE.Item42;
statusServer.xServ = TConsStatServXServ.STATUS;
XmlDocument doc = ObjectToXMLDocument(statusServer);
nfeCabecMsg nfeCabecalho = new nfeCabecMsg();
nfeCabecalho.cUF = "42";
nfeCabecalho.versaoDados = "3.10";
NfeStatusServico2Soap12Client statusServicoClient = new NfeStatusServico2Soap12Client();
System.ServiceModel.EndpointAddress endereco = new System.ServiceModel.EndpointAddress("https://homologacao.nfe.sefaz.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx");
statusServicoClient.Endpoint.Address = endereco;
statusServicoClient.ClientCredentials.ClientCertificate.Certificate = certificado;
var retorno = statusServicoClient.nfeStatusServicoNF2(ref nfeCabecalho, doc);
Through the browser he asks me for the certificate and I can access the WS. I’ve tried using the calls:
X509Certificate2 certificado = new X509Certificate2(caminho, senha, X509KeyStorageFlags.MachineKeySet);
System.ServiceModel.EndpointAddress endereco = new System.ServiceModel.EndpointAddress("https://homologacao.nfe.sefaz.rs.gov.br/ws/NfeStatusServico/NfeStatusServico2.asmx?WSDL");
Are you encountering difficulties only in version "3.10" or "2.00" as well? Also, the CNPJ of the authorized certificate is the same certificate you are using to call the query?
– rodrigogq