GARANTIR DESCONTO

Fórum Consumir web service NFe 4.0 #594603

01/06/2018

0

C#

Por favor alguém pode me ajudar a adaptar este código consumir web service em C# da NFe 3.10 para a 4.0?
//Consumir WebService
switch (NFe.Properties.Settings.Default.NFE_UF)
{
case "DF": //53
{
switch (NFe.Properties.Settings.Default.NFE_tpAmb)
{
case "1": //Produção
{
// NFe.P_SVRS_NFeConsultaProtocolo2.nfeCabecMsg wsCab_SVRS = new NFe.P_SVRS_NFeConsultaProtocolo2.nfeCabecMsg();
// NFe.P_SVRS_NFeConsultaProtocolo2.NfeConsulta2 wsSer_SVRS = new NFe.P_SVRS_NFeConsultaProtocolo2.NfeConsulta2();

// NFe.P_DF_SVRS_NFeConsulta.nfeCabecMsg wsCab_SVRS = new NFe.P_DF_SVRS_NFeConsulta.nfeCabecMsg();
// NFe.P_DF_SVRS_NFeConsulta.NfeConsulta2 wsSer_SVRS = new NFe.P_DF_SVRS_NFeConsulta.NfeConsulta2();
NFe.PROD_NFCE_DF_CONS.nfeCabecMsg wsCab_SVRS = new NFe.PROD_NFCE_DF_CONS.nfeCabecMsg();
NFe.PROD_NFCE_DF_CONS.NfeConsulta2 wsSer_SVRS = new NFe.PROD_NFCE_DF_CONS.NfeConsulta2();


wsCab_SVRS.cUF = NFe.Properties.Settings.Default.NFE_cUF;
// wsCab_SVRS.versaoDados = "3.10";
wsCab_SVRS.versaoDados = "2.01";

wsSer_SVRS.nfeCabecMsgValue = wsCab_SVRS;

// Adicionar o Certificado Digital
wsSer_SVRS.ClientCertificates.Add(certificado);

XmlNode xmlDados_SVRS;
xmlDados_SVRS = xml_ConsSitNFe.DocumentElement;

xml_retornado.LoadXml(wsSer_SVRS.nfeConsultaNF2(xmlDados_SVRS).OuterXml);

xml_retornado.Save(nome_completo_xml_nfe_retornado);

MessageBox.Show(xml_retornado.OuterXml.ToString());

break;
}
case "2": //Homologação
{
// NFe.HOMOL_NfeConsultaProtocolo2.nfeCabecMsg wsCab_DF = new NFe.HOMOL_NfeConsultaProtocolo2.nfeCabecMsg();
// NFe.HOMOL_NfeConsultaProtocolo2.NfeConsulta2 wsSer_DF = new NFe.HOMOL_NfeConsultaProtocolo2.NfeConsulta2();

// NFe.H_DF_SVRS_ConsultaProtocolo2.nfeCabecMsg wsCab_DF = new NFe.H_DF_SVRS_ConsultaProtocolo2.nfeCabecMsg();
// NFe.H_DF_SVRS_ConsultaProtocolo2.NfeConsulta2 wsSer_DF = new NFe.H_DF_SVRS_ConsultaProtocolo2.NfeConsulta2();

br.gov.rs.svrs.nfce_homologacao_consulta.nfeCabecMsg wsCab_DF = new br.gov.rs.svrs.nfce_homologacao_consulta.nfeCabecMsg();
br.gov.rs.svrs.nfce_homologacao_consulta.NfeConsulta2 wsSer_DF = new br.gov.rs.svrs.nfce_homologacao_consulta.NfeConsulta2();


wsCab_DF.cUF = NFe.Properties.Settings.Default.NFE_cUF;
wsCab_DF.versaoDados = "2.01";
// wsCab_DF.versaoDados = "3.10";

wsSer_DF.nfeCabecMsgValue = wsCab_DF;

// Adicionar o Certificado Digital
wsSer_DF.ClientCertificates.Add(certificado);

XmlNode xmlDados;
xmlDados = xml_ConsSitNFe.DocumentElement;

xml_retornado.LoadXml(wsSer_DF.nfeConsultaNF2(xmlDados).OuterXml);

xml_retornado.Save(nome_completo_xml_nfe_retornado);

MessageBox.Show(xml_retornado.OuterXml.ToString());

break;
}
}
break;
}
Laudimar Brito

Laudimar Brito

Responder

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar