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 | |||
| 11 | import br.inf.portalfiscal.nfe.schema_4.consStatServ.TConsStatServ; |
||
| 12 | import br.inf.portalfiscal.nfe.schema_4.retConsStatServ.TRetConsStatServ; |
||
| 13 | import br.inf.portalfiscal.www.nfe_400.wsdl.NFeStatusServico4.NFeStatusServico4Stub; |
||
| 14 | import nfe.dom.ConfiguracoesIniciaisNfe; |
||
| 15 | import nfe.exception.NfeException; |
||
| 16 | import nfe.util.CertificadoUtil; |
||
| 17 | import nfe.util.ConstantesUtil; |
||
| 18 | import nfe.util.WebServiceUtil; |
||
| 19 | import nfe.util.XmlUtil; |
||
| 20 | |||
| 21 | |||
| 22 | /** |
||
| 23 | * Classe responsavel por fazer a Verificacao do Status Do Webservice |
||
| 24 | * |
||
| 25 | * @author Samuel Oliveira |
||
| 26 | * |
||
| 27 | */ |
||
| 28 | class Status { |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Metodo para Consulta de Status de Serviço |
||
| 32 | * |
||
| 33 | * @param tipo ConstantesUtil.NFE e ConstantesUtil.NFCE |
||
| 34 | * @return |
||
| 35 | * @throws NfeException |
||
| 36 | */ |
||
| 37 | static TRetConsStatServ statusServico(String tipo) throws NfeException { |
||
| 38 | |||
| 39 | try { |
||
| 40 | ConfiguracoesIniciaisNfe config = CertificadoUtil.iniciaConfiguracoes(); |
||
| 41 | |||
| 42 | TConsStatServ consStatServ = new TConsStatServ(); |
||
| 43 | consStatServ.setTpAmb(config.getAmbiente()); |
||
| 44 | consStatServ.setCUF(config.getEstado().getCodigoIbge()); |
||
| 45 | consStatServ.setVersao(config.getVersaoNfe()); |
||
| 46 | consStatServ.setXServ("STATUS"); |
||
| 47 | String xml = XmlUtil.objectToXml(consStatServ); |
||
| 48 | |||
| 49 | if (config.isLog()) { |
||
| 50 | System.out.println("Xml Status: " + xml); |
||
| 51 | } |
||
| 52 | OMElement ome = AXIOMUtil.stringToOM(xml); |
||
| 53 | |||
| 54 | NFeStatusServico4Stub.NfeDadosMsg dadosMsg = new NFeStatusServico4Stub.NfeDadosMsg(); |
||
| 55 | dadosMsg.setExtraElement(ome); |
||
| 56 | |||
| 57 | NFeStatusServico4Stub stub = new NFeStatusServico4Stub(tipo.equals(ConstantesUtil.NFCE) ? WebServiceUtil.getUrl(ConstantesUtil.NFCE, ConstantesUtil.SERVICOS.STATUS_SERVICO) : WebServiceUtil.getUrl(ConstantesUtil.NFE, ConstantesUtil.SERVICOS.STATUS_SERVICO)); |
||
| 58 | NFeStatusServico4Stub.NfeResultMsg result = stub.nfeStatusServicoNF(dadosMsg); |
||
| 59 | |||
| 60 | return XmlUtil.xmlToObject(result.getExtraElement().toString(), TRetConsStatServ.class); |
||
| 61 | |||
| 62 | } catch (RemoteException | XMLStreamException | JAXBException e) { |
||
| 63 | throw new NfeException(e.getMessage()); |
||
| 64 | } |
||
| 65 | |||
| 66 | } |
||
| 67 | |||
| 68 | } |