maudruidas Posted January 20, 2023 Report Share Posted January 20, 2023 Bom dia, menu sistema em modo de Produção está funcionando perfeitamente, porém, em modo de Homologação ao buscar o recibo ele di que não foi possível encontrar na Sefaz. Pelo site da Sefaz verifiquei que a Nfe está lá. Vocês saberiam me dizer se mudou alguma coisa na Sefaz?. Vejam como faço para consultar: Xml de envio: <?xml version="1.0" encoding="UTF-8"?> -<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> -<soap12:Body> -<nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NFeRetAutorizacao4"> -<consReciNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00"> <tpAmb>2</tpAmb> <nRec>351000172228685</nRec> </consReciNFe> </nfeDadosMsg> </soap12:Body> </soap12:Envelope> Função de Envio: Function ConsultaRecibo(cChaveNfe,lBotao,lRecibo,cRecibo,cNomeComando) //----------------------------------------------------// local response ,oXmlDocons ,cStat ,cRet Local cXml:="" ,nFileHandle Local oXmldsig,oSchema,cArqXml,cAss,dsigKey,cXMLEnv,x,cXmlRet,cwsdl,lErro:=.f. Local aFiles,oCertificates,oStore,oCertificados,oCertSelecao,A1Certificate,signedKey,np,nresult,PosFim,PosIni Local mI ,cSubjectName ,cCN:="",oServerWS ,cCERT ,aRETORNO,e,oError,n Local assinar,assinatura,oTxt ,cxXml,sNamespace,objSchemas,oXSD ,oErr Local eXml,rXml,cSoapAction,cContentType ,oXmlURI ,oXmlNode ,oMotivo,oSoapAction Local cNameCertific,cHost,oDOMDocons Default lBotao:=.F.,lRecibo:=.F.,cRecibo:='' DEFAULT cChaveNfe := NFCCAB->ChaveNFE SELE 28 tpAmb := STR(HOMPRO,1) if Empty(cChaveNfe) Return "Chave NFe não informada" Endif if Empty(cRecibo) Return "Número de recibo não localizado " Endif try oDOMDocons := xhb_CreateObject( _MSXML2_DOMDocument ) oDOMDocons:async := .F. oDOMDocons:resolveExternals := .F. oDOMDocons:validateOnParse := .T. oDOMDocons:preserveWhiteSpace := .T. catch Return "Problema ao criar objetos solicitados." end cXml+='<?xml version="1.0" encoding="utf-8"?>' cXml+='<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">' cXml+='<soap12:Body>' cXml+='<nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NFeRetAutorizacao4">' cXml+='<consReciNFe versao="4.00" xmlns="http://www.portalfiscal.inf.br/nfe">' cXml+="<tpAmb>"+tpAmb+"</tpAmb>" cXml+='<nRec>'+cRecibo+'</nRec>' cXml+='</consReciNFe>' cXml+='</nfeDadosMsg>' cXml+='</soap12:Body>' cXml+='</soap12:Envelope>' //Cria o XML em arquivo nFileHandle:=FCreate('.\temp\CONSULTA_NFE.XML',) FWrite(nFileHandle,cXml) FClose(nFileHandle) if cNomeComando =="SCAN" cUrl:=m->hDados['NFEReciboSCAN'] Else cUrl:=m->hDados['NFERecibo'] Endif cHost:=strtran(cUrl,"https://","") cHost:=strtran(cHost,"http://","") cHost:='www.'+substr(cHost,1,AT("/",cHost)-1) oServerWS:= xhb_CreateObject( _MSXML2_ServerXMLHTTP ) oServerWS:open('POST',m->hDados['NFERecibo'] , .F.) oServerWS:setRequestHeader('Content-Type','application/soap+xml; charset=utf-8') oServerWS:setRequestHeader('SoapAction',m->hDados['NFERecibo']) // if !empty(m->hDados['A1Certificate']) // somente para certificado A1 // Seleciona o Cetificado para envio do xml com credenciais cCN:=m->hDados["SubjectName"] cNameCertific:=substr(cCN,4,AT(",",cCN)-4) oServerWS:setoption( 3,Alltrim(cNameCertific)) // Endif oDOMDocons:LoadXML(cXml) //-------------------------HOST DE ENVIO------------------------------------// if VerificaXmlValido(oDOMDocons) Try oServerWS:send(oDOMDocons) CATCH e RETURN 'Falha2: Não foi possível conectar-se ao servidor do SEFAZ, Servidor inativo ou inoperante.' END else return "F" endif DO WHILE oServerWS:readyState <> 4 Millisec(5000) ENDDO //cErroRet:='' response := oServerWS:responseText oXmlDocons := TXmlDocument():new() oXmlDocons:read( response ) response := REMOVEACENTO( response , cNomeComando) SaveFile( ".\temp\RepRecibo.xml", response) Return response Ele sempre para na mensagem em negrito acima ou retorna em branco. Quote Link to comment Share on other sites More sharing options...
Helton Aparecido Silva Posted February 10, 2023 Report Share Posted February 10, 2023 Estou com o mesmo problema que você e é horrivel parecer estar fazendo tudo certo, mas não funciona. Estou no aguardo de uma solução, obtendo a posto aqui. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.