Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package nfe; |
| 2 | |||
| 3 | import java.rmi.RemoteException; |
||
| 4 | |||
| 5 | import javax.xml.bind.JAXBException; |
||
| 6 | import javax.xml.stream.XMLStreamException; |
||
| 7 | |||
| 8 | import org.apache.axiom.om.OMElement; |
||
| 9 | import org.apache.axiom.om.util.AXIOMUtil; |
||
| 10 | import org.apache.axis2.transport.http.HTTPConstants; |
||
| 11 | |||
| 12 | import br.inf.portalfiscal.nfe.schema_4.consReciNFe.TConsReciNFe; |
||
| 13 | import br.inf.portalfiscal.nfe.schema_4.retConsReciNFe.TRetConsReciNFe; |
||
| 14 | import br.inf.portalfiscal.www.nfe_400.wsdl.NFeRetAutorizacao.NFeRetAutorizacao4Stub; |
||
| 15 | import nfe.dom.ConfiguracoesIniciaisNfe; |
||
| 16 | import nfe.exception.NfeException; |
||
| 17 | import nfe.util.CertificadoUtil; |
||
| 18 | import nfe.util.ConstantesUtil; |
||
| 19 | import nfe.util.ObjetoUtil; |
||
| 20 | import nfe.util.WebServiceUtil; |
||
| 21 | import nfe.util.XmlUtil; |
||
| 22 | |||
| 23 | |||
| 24 | /** |
||
| 25 | * Classe Responsavel Por pegar o Retorno da NFE, apos o Envio. |
||
| 26 | * |
||
| 27 | * @author Samuel Oliveira |
||
| 28 | */ |
||
| 29 | class ConsultaRecibo { |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Metodo Responsavel Por Pegar o Xml De Retorno. |
||
| 33 | * |
||
| 34 | * @param tConsReciNFe |
||
| 35 | * @param valida |
||
| 36 | * @param tipo |
||
| 37 | * @return |
||
| 38 | * @throws NfeException |
||
| 39 | */ |
||
| 40 | |||
| 41 | static TRetConsReciNFe reciboNfe(String recibo, String tipo) throws NfeException { |
||
| 42 | |||
| 43 | try { |
||
| 44 | |||
| 45 | /** |
||
| 46 | * InformaƧoes do Certificado Digital. |
||
| 47 | */ |
||
| 48 | ConfiguracoesIniciaisNfe configuracoesNfe = CertificadoUtil.iniciaConfiguracoes(); |
||
| 49 | |||
| 50 | TConsReciNFe consReciNFe = new TConsReciNFe(); |
||
| 51 | consReciNFe.setVersao(configuracoesNfe.getVersaoNfe()); |
||
| 52 | consReciNFe.setTpAmb(configuracoesNfe.getAmbiente()); |
||
| 53 | consReciNFe.setNRec(recibo); |
||
| 54 | |||
| 55 | String xml = XmlUtil.objectToXml(consReciNFe); |
||
| 56 | |||
| 57 | OMElement ome = AXIOMUtil.stringToOM(xml); |
||
| 58 | NFeRetAutorizacao4Stub.NfeDadosMsg dadosMsg = new NFeRetAutorizacao4Stub.NfeDadosMsg(); |
||
| 59 | dadosMsg.setExtraElement(ome); |
||
| 60 | |||
| 61 | NFeRetAutorizacao4Stub stub = new NFeRetAutorizacao4Stub(tipo.equals(ConstantesUtil.NFCE) ? WebServiceUtil.getUrl(ConstantesUtil.NFCE, ConstantesUtil.SERVICOS.CONSULTA_RECIBO) : WebServiceUtil.getUrl(ConstantesUtil.NFE, ConstantesUtil.SERVICOS.CONSULTA_RECIBO)); |
||
| 62 | //Timeout |
||
| 63 | if (!ObjetoUtil.isEmpty(configuracoesNfe.getTimeout())) { |
||
| 64 | stub._getServiceClient().getOptions().setProperty( |
||
| 65 | HTTPConstants.SO_TIMEOUT, configuracoesNfe.getTimeout()); |
||
| 66 | stub._getServiceClient().getOptions().setProperty( |
||
| 67 | HTTPConstants.CONNECTION_TIMEOUT, configuracoesNfe.getTimeout()); |
||
| 68 | } |
||
| 69 | NFeRetAutorizacao4Stub.NfeResultMsg result = stub.nfeRetAutorizacaoLote(dadosMsg); |
||
| 70 | |||
| 71 | return XmlUtil.xmlToObject(result.getExtraElement().toString(), TRetConsReciNFe.class); |
||
| 72 | |||
| 73 | } catch (RemoteException | XMLStreamException | JAXBException e) { |
||
| 74 | throw new NfeException(e.getMessage()); |
||
| 75 | } |
||
| 76 | |||
| 77 | } |
||
| 78 | } |