From fd77ce22db1395471e181a66d45e6b2b73773928 Mon Sep 17 00:00:00 2001 From: Luciano Antunes Date: Mon, 9 Dec 2024 10:52:47 -0300 Subject: [PATCH 1/2] =?UTF-8?q?Distribui=C3=A7=C3=A3o=20MDFe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...odalAquaviarioConteinerInfoDocumentos.java | 2 +- .../mdfe3/classes/MDFAutorizador3.java | 9 ++++ .../MDFInfoModalRodoviarioInfContratante.java | 18 ++++++- .../nota/MDFInfoModalRodoviarioPedagio.java | 48 +++++++++++++------ .../MDFInfoModalRodoviarioPedagioDisp.java | 19 +++++++- .../MDFInfoModalRodoviarioVeiculoProp.java | 4 +- .../nota/MDFInfoProdutoPredominante.java | 6 +-- ...utoPredominanteInfLotacaoLocalCarrega.java | 4 +- ...PredominanteInfLotacaoLocalDescarrega.java | 4 +- .../mdfe3/classes/nota/MDFRespTec.java | 15 ++++-- .../mdfe3/webservices/WSFacade.java | 40 ++++++++++++---- .../classes/nota/NFNotaInfoDestinatario.java | 8 +++- .../validadores/DFXMLValidador.java | 11 +++++ 13 files changed, 143 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/fincatto/documentofiscal/cte400/classes/nota/CTeNotaInfoCTeNormalInfoModalAquaviarioConteinerInfoDocumentos.java b/src/main/java/com/fincatto/documentofiscal/cte400/classes/nota/CTeNotaInfoCTeNormalInfoModalAquaviarioConteinerInfoDocumentos.java index ffde5aad4..68f9fa352 100644 --- a/src/main/java/com/fincatto/documentofiscal/cte400/classes/nota/CTeNotaInfoCTeNormalInfoModalAquaviarioConteinerInfoDocumentos.java +++ b/src/main/java/com/fincatto/documentofiscal/cte400/classes/nota/CTeNotaInfoCTeNormalInfoModalAquaviarioConteinerInfoDocumentos.java @@ -17,7 +17,7 @@ public class CTeNotaInfoCTeNormalInfoModalAquaviarioConteinerInfoDocumentos extends DFBase { private static final long serialVersionUID = 2746254923817166298L; - @ElementList(name = "infNF", inline = true) + @ElementList(name = "infNF", inline = true, required = false) private List infoDocumentosNF; @ElementList(name = "infNFe", inline = true) diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/MDFAutorizador3.java b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/MDFAutorizador3.java index 135416172..397dbfe8a 100644 --- a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/MDFAutorizador3.java +++ b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/MDFAutorizador3.java @@ -69,6 +69,13 @@ public String getMDFeConsNaoEnc(DFAmbiente ambiente) { : "https://mdfe.svrs.rs.gov.br/ws/MDFeConsNaoEnc/MDFeConsNaoEnc.asmx"; } + @Override + public String getMDFeDistribuicao(DFAmbiente ambiente) { + return DFAmbiente.HOMOLOGACAO.equals(ambiente) + ? "https://mdfe-homologacao.svrs.rs.gov.br/ws/MDFeDistribuicaoDFe/MDFeDistribuicaoDFe.asmx" + : "https://mdfe.svrs.rs.gov.br/ws/MDFeDistribuicaoDFe/MDFeDistribuicaoDFe.asmx"; + } + @Override public DFUnidadeFederativa[] getUFs() { return new DFUnidadeFederativa[]{DFUnidadeFederativa.RS}; @@ -88,6 +95,8 @@ public DFUnidadeFederativa[] getUFs() { public abstract String getMDFeConsulta(final DFAmbiente ambiente); public abstract String getMDFeConsNaoEnc(final DFAmbiente ambiente); + + public abstract String getMDFeDistribuicao(final DFAmbiente ambiente); public abstract DFUnidadeFederativa[] getUFs(); diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioInfContratante.java b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioInfContratante.java index 937ca1c7c..c0fb72868 100644 --- a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioInfContratante.java +++ b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioInfContratante.java @@ -1,8 +1,9 @@ package com.fincatto.documentofiscal.mdfe3.classes.nota; -import com.fincatto.documentofiscal.validadores.DFStringValidador; import org.simpleframework.xml.Element; +import com.fincatto.documentofiscal.validadores.DFStringValidador; + /** * Created by Eldevan Nery Junior on 01/11/17. * @@ -11,6 +12,12 @@ */ public class MDFInfoModalRodoviarioInfContratante { + /** + *

Nome do contratente do serviço.

+ */ + @Element(name = "xNome", required = false) + private String nome; + /** *

Número do CPF do contratente do serviço.

*/ @@ -29,6 +36,15 @@ public class MDFInfoModalRodoviarioInfContratante { @Element(name = "idEstrangeiro", required = false) private String idEstrangeiro; + public String getNome() { + return nome; + } + + public void setNome(String nome) { + DFStringValidador.validaIntervalo(nome, 2, 60, "Nome"); + this.nome = nome; + } + public String getCpf() { return cpf; } diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioPedagio.java b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioPedagio.java index 658acfb49..83cd23da7 100644 --- a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioPedagio.java +++ b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioPedagio.java @@ -2,6 +2,7 @@ import java.util.List; +import org.simpleframework.xml.Element; import org.simpleframework.xml.ElementList; import org.simpleframework.xml.Root; @@ -12,23 +13,40 @@ * Created by Eldevan Nery Junior on 01/11/17. *

Informações de Vale Pedágio.

*

- * Outras informações sobre Vale-Pedágio obrigatório que não tenham campos específicos devem ser informadas no campo de observações gerais de uso livre pelo contribuinte, visando atender as determinações legais vigentes. + * Outras informações sobre Vale-Pedágio obrigatório que não tenham campos + * específicos devem ser informadas no campo de observações gerais de uso livre + * pelo contribuinte, visando atender as determinações legais vigentes. *

*/ @Root(name = "valePed") public class MDFInfoModalRodoviarioPedagio extends DFBase { - private static final long serialVersionUID = 3657414548123273405L; - /** - * Lista de dispositivos do Vale Pedágio. - */ - @ElementList(entry = "disp", inline = true) - private List dispositivos; - - public List getDispositivos() { - return this.dispositivos; - } - - public void setDispositivos(final List dispositivos) { - this.dispositivos = DFListValidador.validaListaObrigatoria(dispositivos, "Dispositivos do Vale Pedagio"); - } + private static final long serialVersionUID = 3657414548123273405L; + /** + * Lista de dispositivos do Vale Pedágio. + */ + @ElementList(entry = "disp", inline = true) + private List dispositivos; + + /** + *

Categoria do Combinação Veicular

+ */ + @Element(name = "categCombVeic", required = false) + private String categoriaCombinacaoVeicular; + + public List getDispositivos() { + return this.dispositivos; + } + + public void setDispositivos(final List dispositivos) { + this.dispositivos = DFListValidador.validaListaObrigatoria(dispositivos, "Dispositivos do Vale Pedagio"); + } + + public String getCategoriaCombinacaoVeicular() { + return categoriaCombinacaoVeicular; + } + + public void setCategoriaCombinacaoVeicular(String categoriaCombinacaoVeicular) { + this.categoriaCombinacaoVeicular = categoriaCombinacaoVeicular; + } + } diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioPedagioDisp.java b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioPedagioDisp.java index 37d2d718b..b3d057782 100644 --- a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioPedagioDisp.java +++ b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioPedagioDisp.java @@ -31,7 +31,7 @@ public class MDFInfoModalRodoviarioPedagioDisp extends DFBase { /** *

CPF do responsável pelo pagamento do Vale-Pedágio

*/ - @Element(name = "CPFPg") + @Element(name = "CPFPg", required = false) protected String cpfPagadora; /** @@ -40,7 +40,7 @@ public class MDFInfoModalRodoviarioPedagioDisp extends DFBase { * Número de ordem do comprovante de compra do Vale-Pedágio fornecido para cada veículo ou combinação veicular, por viagem. *

*/ - @Element(name = "nCompra") + @Element(name = "nCompra", required = false) private String numeroComprovante; /** @@ -49,6 +49,12 @@ public class MDFInfoModalRodoviarioPedagioDisp extends DFBase { @Element(name = "vValePed") private String valor; + /** + *

Tipo do Vale-Pedagio

+ */ + @Element(name = "tpValePed", required = false) + private String tipoValePedagio; + public String getCnpjFornecedora() { return this.cnpjFornecedora; } @@ -98,4 +104,13 @@ public void setCpfPagadora(final String cpfPagadora) { DFStringValidador.cpf(cpfPagadora); this.cpfPagadora = cpfPagadora; } + + public String getTipoValePedagio() { + return tipoValePedagio; + } + + public void setTipoValePedagio(String tipoValePedagio) { + this.tipoValePedagio = tipoValePedagio; + } + } diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioVeiculoProp.java b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioVeiculoProp.java index 18b99f4fa..69be30332 100644 --- a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioVeiculoProp.java +++ b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoModalRodoviarioVeiculoProp.java @@ -22,13 +22,13 @@ public class MDFInfoModalRodoviarioVeiculoProp extends DFBase { @Element(name = "xNome") private String razaoSocial; - @Element(name = "IE") + @Element(name = "IE", required = false) private String inscricaoEstadual; @Element(name = "UF") private String unidadeFederativa; - @Element(name = "tpProp", required = false) + @Element(name = "tpProp") private MDFTipoProprietario tipoProprietario; public String getCpf() { diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoProdutoPredominante.java b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoProdutoPredominante.java index 1f0996d07..599bd0079 100644 --- a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoProdutoPredominante.java +++ b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoProdutoPredominante.java @@ -25,13 +25,13 @@ public class MDFInfoProdutoPredominante extends DFBase { @Element(name="xProd", required = true) private String xProd; - @Element(name = "cEAN") + @Element(name = "cEAN", required = false) private String cEAN; - @Element(name = "NCM") + @Element(name = "NCM", required = false) private String NCM; - @Element(name = "infLotacao") + @Element(name = "infLotacao", required = false) private MDFInfoProdutoPredominanteInfLotacao infLotacao; public MDFTipoCargaProdutoPredominante getTpCarga() { diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoProdutoPredominanteInfLotacaoLocalCarrega.java b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoProdutoPredominanteInfLotacaoLocalCarrega.java index 41dc8c168..bbc37f0ef 100644 --- a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoProdutoPredominanteInfLotacaoLocalCarrega.java +++ b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoProdutoPredominanteInfLotacaoLocalCarrega.java @@ -18,10 +18,10 @@ public class MDFInfoProdutoPredominanteInfLotacaoLocalCarrega extends DFBase { @Element(name = "CEP", required = false) private String CEP; - @Element(name = "latitude", required = false) + @Element(name = "latitude", required = true) private Float latitude; - @Element(name = "longitude", required = false) + @Element(name = "longitude", required = true) private Float longitude; public String getCEP() { diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoProdutoPredominanteInfLotacaoLocalDescarrega.java b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoProdutoPredominanteInfLotacaoLocalDescarrega.java index 6923ecf78..dfa5f4708 100644 --- a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoProdutoPredominanteInfLotacaoLocalDescarrega.java +++ b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFInfoProdutoPredominanteInfLotacaoLocalDescarrega.java @@ -18,10 +18,10 @@ public class MDFInfoProdutoPredominanteInfLotacaoLocalDescarrega extends DFBase @Element(name = "CEP", required = false) private String CEP; - @Element(name = "latitude", required = false) + @Element(name = "latitude", required = true) private Float latitude; - @Element(name = "longitude", required = false) + @Element(name = "longitude", required = true) private Float longitude; public String getCEP() { diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFRespTec.java b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFRespTec.java index 0a45a3f64..791931e14 100644 --- a/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFRespTec.java +++ b/src/main/java/com/fincatto/documentofiscal/mdfe3/classes/nota/MDFRespTec.java @@ -25,15 +25,20 @@ public class MDFRespTec { @Element(name = "CNPJ", required = true) private String cnpj; - @Element(required = true) + + @Element(name = "xContato", required = true) private String xContato; - @Element(required = true) + + @Element(name = "email", required = true) private String email; - @Element(required = true) + + @Element(name = "fone", required = true) private String fone; - @Element + + @Element(name = "idCSRT", required = false) private String idCSRT; - @Element + + @Element(name = "hashCSRT", required = false) private byte[] hashCSRT; /** diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe3/webservices/WSFacade.java b/src/main/java/com/fincatto/documentofiscal/mdfe3/webservices/WSFacade.java index faf0b0ebe..a301a1639 100644 --- a/src/main/java/com/fincatto/documentofiscal/mdfe3/webservices/WSFacade.java +++ b/src/main/java/com/fincatto/documentofiscal/mdfe3/webservices/WSFacade.java @@ -1,6 +1,19 @@ package com.fincatto.documentofiscal.mdfe3.webservices; +import java.io.IOException; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; +import java.time.LocalDate; +import java.util.List; + +import org.apache.commons.httpclient.protocol.Protocol; + import com.fincatto.documentofiscal.DFUnidadeFederativa; +import com.fincatto.documentofiscal.mdfe.classes.distribuicao.MDFeDistribuicaoIntRetorno; +import com.fincatto.documentofiscal.mdfe.webservices.distribuicao.WSDistribuicaoMDFe; import com.fincatto.documentofiscal.mdfe3.MDFeConfig; import com.fincatto.documentofiscal.mdfe3.classes.consultaRecibo.MDFeConsultaReciboRetorno; import com.fincatto.documentofiscal.mdfe3.classes.consultanaoencerrados.MDFeConsultaNaoEncerradosRetorno; @@ -15,16 +28,6 @@ import com.fincatto.documentofiscal.mdfe3.classes.nota.evento.MDFeEnviaEventoIncluirDFeInfDoc; import com.fincatto.documentofiscal.mdfe3.classes.nota.evento.MDFeRetorno; import com.fincatto.documentofiscal.utils.DFSocketFactory; -import org.apache.commons.httpclient.protocol.Protocol; - -import java.io.IOException; -import java.security.KeyManagementException; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; -import java.security.cert.CertificateException; -import java.time.LocalDate; -import java.util.List; public class WSFacade { @@ -39,6 +42,7 @@ public class WSFacade { private final WSIncluirCondutor wsIncluirCondutor; private final WSIncluirDFe wsIncluirDFe; private final WSPagamentoTransporte wsPagamentoTransporte; + private final WSDistribuicaoMDFe wsDistribuicaoMDFe; // private final WSRecepcaoLoteRetorno wsRecepcaoLoteRetorno; public WSFacade(final MDFeConfig config) throws IOException, KeyManagementException, UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException, CertificateException { @@ -55,6 +59,7 @@ public WSFacade(final MDFeConfig config) throws IOException, KeyManagementExcept this.wsIncluirCondutor = new WSIncluirCondutor(config); this.wsIncluirDFe = new WSIncluirDFe(config); this.wsPagamentoTransporte = new WSPagamentoTransporte(config); + this.wsDistribuicaoMDFe = new WSDistribuicaoMDFe(config); } /** @@ -277,4 +282,19 @@ public MDFeRetorno pagamentoTransporte(final String chaveAcesso, final String nP public MDFeRetorno pagamentoTransporteAssinado(final String chaveAcesso, final String eventoAssinadoXml) throws Exception { return this.wsPagamentoTransporte.pagamentoAssinado(chaveAcesso, eventoAssinadoXml); } + + /** + * Faz consulta de distribuicao dos MDFe. + * + * @param cpfOuCnpj + * @param uf + * @param nsu + * @param ultNsu + * @return + * @throws Exception + */ + public MDFeDistribuicaoIntRetorno consultarDistribuicaoMDFe(final String cpfOuCnpj, final DFUnidadeFederativa uf, final String nsu, final String ultNsu) throws Exception { + return this.wsDistribuicaoMDFe.consultar(cpfOuCnpj, uf, nsu, ultNsu); + } + } diff --git a/src/main/java/com/fincatto/documentofiscal/nfe400/classes/nota/NFNotaInfoDestinatario.java b/src/main/java/com/fincatto/documentofiscal/nfe400/classes/nota/NFNotaInfoDestinatario.java index 79cc00a18..ddc21be2a 100755 --- a/src/main/java/com/fincatto/documentofiscal/nfe400/classes/nota/NFNotaInfoDestinatario.java +++ b/src/main/java/com/fincatto/documentofiscal/nfe400/classes/nota/NFNotaInfoDestinatario.java @@ -1,10 +1,13 @@ package com.fincatto.documentofiscal.nfe400.classes.nota; +import org.apache.commons.lang3.StringUtils; +import org.simpleframework.xml.Element; +import org.simpleframework.xml.convert.Convert; + import com.fincatto.documentofiscal.DFBase; import com.fincatto.documentofiscal.nfe400.classes.NFEndereco; +import com.fincatto.documentofiscal.nfe400.converters.NFStringNullToEmptyConverter; import com.fincatto.documentofiscal.validadores.DFStringValidador; -import org.apache.commons.lang3.StringUtils; -import org.simpleframework.xml.Element; public class NFNotaInfoDestinatario extends DFBase { private static final long serialVersionUID = 5245421887189198219L; @@ -16,6 +19,7 @@ public class NFNotaInfoDestinatario extends DFBase { private String cpf; @Element(name = "idEstrangeiro", required = false) + @Convert(NFStringNullToEmptyConverter.class) private String idEstrangeiro; @Element(name = "xNome", required = false) diff --git a/src/main/java/com/fincatto/documentofiscal/validadores/DFXMLValidador.java b/src/main/java/com/fincatto/documentofiscal/validadores/DFXMLValidador.java index 9bcf6ad3c..c851c7ef5 100644 --- a/src/main/java/com/fincatto/documentofiscal/validadores/DFXMLValidador.java +++ b/src/main/java/com/fincatto/documentofiscal/validadores/DFXMLValidador.java @@ -223,6 +223,17 @@ public static boolean validaDistribuicaoCTe(final String arquivoXML) throws IOEx return DFXMLValidador.validaDistribuicaoCTe(arquivoXML, "distDFeInt_v1.00.xsd"); } + private static boolean validaDistribuicaoMDFe(final String xml, final String xsd) throws IOException, SAXException, URISyntaxException { + final URL xsdPath = DFXMLValidador.class.getClassLoader().getResource(String.format("schemas/PL_MDFeDistDFe_100/%s", xsd)); + final SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); + final Schema schema = schemaFactory.newSchema(new StreamSource(xsdPath.toURI().toString())); + schema.newValidator().validate(new StreamSource(new StringReader(xml))); + return true; + } + public static boolean validaDistribuicaoMDFe(final String arquivoXML) throws IOException, SAXException, URISyntaxException { + return DFXMLValidador.validaDistribuicaoMDFe(arquivoXML, "distDFeInt_v1.00.xsd"); + } + public static boolean validaConsultaDfe(final String arquivoXML) throws Exception { return DFXMLValidador.validaDfe(arquivoXML, "distDFeInt_v1.01.xsd"); } From b926c410b9e1c16b60700d1ed11cbfeae5cabbb7 Mon Sep 17 00:00:00 2001 From: Luciano Antunes Date: Mon, 9 Dec 2024 15:54:58 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Distribui=C3=A7=C3=A3o=20MDFe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MDFeDistribuicaoConsultaNSU.java | 23 + .../distribuicao/MDFeDistribuicaoDFeLote.java | 23 + .../MDFeDistribuicaoDocumentoZip.java | 49 + .../distribuicao/MDFeDistribuicaoInt.java | 82 + .../MDFeDistribuicaoIntRetorno.java | 115 + .../distribuicao/MDFeDistribuicaoNSU.java | 22 + .../distribuicao/MDFeDistribuicaoDFeStub.java | 1916 +++++++++++++++++ .../distribuicao/WSDistribuicaoMDFe.java | 99 + .../PL_MDFeDistDFe_100/distDFeInt_v1.00.xsd | 63 + .../retDistDFeInt_v1.00.xsd | 87 + .../PL_MDFeDistDFe_100/tiposDistDFe_v1.00.xsd | 198 ++ .../tiposGeralMDFe_v1.00.xsd | 606 ++++++ .../xmldsig-core-schema_v1.01.xsd | 98 + 13 files changed, 3381 insertions(+) create mode 100644 src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoConsultaNSU.java create mode 100644 src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoDFeLote.java create mode 100644 src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoDocumentoZip.java create mode 100644 src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoInt.java create mode 100644 src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoIntRetorno.java create mode 100644 src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoNSU.java create mode 100644 src/main/java/com/fincatto/documentofiscal/mdfe/webservices/distribuicao/MDFeDistribuicaoDFeStub.java create mode 100644 src/main/java/com/fincatto/documentofiscal/mdfe/webservices/distribuicao/WSDistribuicaoMDFe.java create mode 100644 src/main/resources/schemas/PL_MDFeDistDFe_100/distDFeInt_v1.00.xsd create mode 100644 src/main/resources/schemas/PL_MDFeDistDFe_100/retDistDFeInt_v1.00.xsd create mode 100644 src/main/resources/schemas/PL_MDFeDistDFe_100/tiposDistDFe_v1.00.xsd create mode 100644 src/main/resources/schemas/PL_MDFeDistDFe_100/tiposGeralMDFe_v1.00.xsd create mode 100644 src/main/resources/schemas/PL_MDFeDistDFe_100/xmldsig-core-schema_v1.01.xsd diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoConsultaNSU.java b/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoConsultaNSU.java new file mode 100644 index 000000000..5ac02c309 --- /dev/null +++ b/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoConsultaNSU.java @@ -0,0 +1,23 @@ +package com.fincatto.documentofiscal.mdfe.classes.distribuicao; + +import org.simpleframework.xml.Element; + +import com.fincatto.documentofiscal.DFBase; + +public class MDFeDistribuicaoConsultaNSU extends DFBase { + + private static final long serialVersionUID = -582191692175285331L; + + @Element(name = "NSU") + private String nsu; + + public String getNsu() { + return this.nsu; + } + + public MDFeDistribuicaoConsultaNSU setNsu(final String nsu) { + this.nsu = nsu; + return this; + } + +} diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoDFeLote.java b/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoDFeLote.java new file mode 100644 index 000000000..efc20e929 --- /dev/null +++ b/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoDFeLote.java @@ -0,0 +1,23 @@ +package com.fincatto.documentofiscal.mdfe.classes.distribuicao; + +import java.util.List; + +import org.simpleframework.xml.ElementList; + +import com.fincatto.documentofiscal.DFBase; + +public class MDFeDistribuicaoDFeLote extends DFBase { + private static final long serialVersionUID = 5213446895183202408L; + + @ElementList(name = "docZip", inline = true, required = false) + private List docZip; + + public List getDocZip() { + return this.docZip; + } + + public MDFeDistribuicaoDFeLote setDocZip(final List docZip) { + this.docZip = docZip; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoDocumentoZip.java b/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoDocumentoZip.java new file mode 100644 index 000000000..b8f3628e8 --- /dev/null +++ b/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoDocumentoZip.java @@ -0,0 +1,49 @@ +package com.fincatto.documentofiscal.mdfe.classes.distribuicao; + +import org.simpleframework.xml.Attribute; +import org.simpleframework.xml.Root; +import org.simpleframework.xml.Text; + +import com.fincatto.documentofiscal.DFBase; + +@Root(name = "docZip") +public class MDFeDistribuicaoDocumentoZip extends DFBase { + private static final long serialVersionUID = -6656266954109936292L; + + @Text + private String value; + + @Attribute(name = "NSU") + private String nsu; + + @Attribute(name = "schema") + private String schema; + + public String getValue() { + return this.value; + } + + public String getNsu() { + return this.nsu; + } + + public MDFeDistribuicaoDocumentoZip setNsu(final String nsu) { + this.nsu = nsu; + return this; + } + + public String getSchema() { + return this.schema; + } + + public MDFeDistribuicaoDocumentoZip setSchema(final String schema) { + this.schema = schema; + return this; + } + + public MDFeDistribuicaoDocumentoZip setValue(final String value) { + this.value = value; + return this; + } + +} \ No newline at end of file diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoInt.java b/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoInt.java new file mode 100644 index 000000000..455fe76e5 --- /dev/null +++ b/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoInt.java @@ -0,0 +1,82 @@ +package com.fincatto.documentofiscal.mdfe.classes.distribuicao; + +import org.simpleframework.xml.Attribute; +import org.simpleframework.xml.Element; +import org.simpleframework.xml.Namespace; +import org.simpleframework.xml.Root; + +import com.fincatto.documentofiscal.DFAmbiente; +import com.fincatto.documentofiscal.DFBase; + +@Root(name = "distDFeInt") +@Namespace(reference = "http://www.portalfiscal.inf.br/mdfe") +public class MDFeDistribuicaoInt extends DFBase { + private static final long serialVersionUID = -7079002577486035141L; + + @Attribute(name = "versao") + private String versao; + + @Element(name = "tpAmb") + private DFAmbiente ambiente; + + @Element(name = "CNPJ", required = false) + private String cnpj; + + @Element(name = "CPF", required = false) + private String cpf; + + @Element(name = "distNSU", required = false) + private MDFeDistribuicaoNSU distribuicao; + + @Element(name = "consNSU", required = false) + private MDFeDistribuicaoConsultaNSU consulta; + + public String getVersao() { + return this.versao; + } + + public void setVersao(final String versao) { + this.versao = versao; + } + + public DFAmbiente getAmbiente() { + return this.ambiente; + } + + public void setAmbiente(final DFAmbiente ambiente) { + this.ambiente = ambiente; + } + + public String getCnpj() { + return this.cnpj; + } + + public void setCnpj(final String cnpj) { + this.cnpj = cnpj; + } + + public String getCpf() { + return this.cpf; + } + + public void setCpf(final String cpf) { + this.cpf = cpf; + } + + public MDFeDistribuicaoNSU getDistribuicao() { + return this.distribuicao; + } + + public void setDistribuicao(final MDFeDistribuicaoNSU distribuicao) { + this.distribuicao = distribuicao; + } + + public MDFeDistribuicaoConsultaNSU getConsulta() { + return this.consulta; + } + + public void setConsulta(final MDFeDistribuicaoConsultaNSU consulta) { + this.consulta = consulta; + } + +} \ No newline at end of file diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoIntRetorno.java b/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoIntRetorno.java new file mode 100644 index 000000000..b42b2f395 --- /dev/null +++ b/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoIntRetorno.java @@ -0,0 +1,115 @@ +package com.fincatto.documentofiscal.mdfe.classes.distribuicao; + +import org.simpleframework.xml.Attribute; +import org.simpleframework.xml.Element; +import org.simpleframework.xml.Namespace; +import org.simpleframework.xml.Root; + +import com.fincatto.documentofiscal.DFAmbiente; +import com.fincatto.documentofiscal.DFBase; + +@Root(name = "retDistDFeInt") +@Namespace(reference = "http://www.portalfiscal.inf.br/mdfe") +public class MDFeDistribuicaoIntRetorno extends DFBase { + private static final long serialVersionUID = 8390916638871236156L; + + @Attribute(name = "versao") + private String versao; + + @Element(name = "tpAmb") + private DFAmbiente ambiente; + + @Element(name = "verAplic") + private String versaoAplicativo; + + @Element(name = "cStat") + private String codigoStatusReposta; + + @Element(name = "xMotivo") + private String motivo; + + @Element(name = "dhResp") + private String dataHoraResposta; + + @Element(name = "ultNSU") + private String ultimoNSU; + + @Element(name = "maxNSU") + private String maximoNSU; + + @Element(name = "loteDistDFeInt", required = false) + private MDFeDistribuicaoDFeLote lote; + + public String getVersao() { + return this.versao; + } + + public void setVersao(final String versao) { + this.versao = versao; + } + + public DFAmbiente getAmbiente() { + return this.ambiente; + } + + public void setAmbiente(final DFAmbiente ambiente) { + this.ambiente = ambiente; + } + + public String getVersaoAplicativo() { + return this.versaoAplicativo; + } + + public void setVersaoAplicativo(final String versaoAplicativo) { + this.versaoAplicativo = versaoAplicativo; + } + + public String getCodigoStatusReposta() { + return this.codigoStatusReposta; + } + + public void setCodigoStatusReposta(final String codigoStatusReposta) { + this.codigoStatusReposta = codigoStatusReposta; + } + + public String getMotivo() { + return this.motivo; + } + + public void setMotivo(final String motivo) { + this.motivo = motivo; + } + + public String getDataHoraResposta() { + return this.dataHoraResposta; + } + + public void setDataHoraResposta(final String dataHoraResposta) { + this.dataHoraResposta = dataHoraResposta; + } + + public String getUltimoNSU() { + return this.ultimoNSU; + } + + public void setUltimoNSU(final String ultimoNSU) { + this.ultimoNSU = ultimoNSU; + } + + public String getMaximoNSU() { + return this.maximoNSU; + } + + public void setMaximoNSU(final String maximoNSU) { + this.maximoNSU = maximoNSU; + } + + public MDFeDistribuicaoDFeLote getLote() { + return this.lote; + } + + public void setLote(final MDFeDistribuicaoDFeLote lote) { + this.lote = lote; + } + +} diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoNSU.java b/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoNSU.java new file mode 100644 index 000000000..d7b041178 --- /dev/null +++ b/src/main/java/com/fincatto/documentofiscal/mdfe/classes/distribuicao/MDFeDistribuicaoNSU.java @@ -0,0 +1,22 @@ +package com.fincatto.documentofiscal.mdfe.classes.distribuicao; + +import org.simpleframework.xml.Element; + +import com.fincatto.documentofiscal.DFBase; + +public class MDFeDistribuicaoNSU extends DFBase { + private static final long serialVersionUID = -50569062199740836L; + + @Element(name = "ultNSU") + private String ultimoNSU; + + public java.lang.String getUltimoNSU() { + return this.ultimoNSU; + } + + public MDFeDistribuicaoNSU setUltimoNSU(final java.lang.String ultimoNSU) { + this.ultimoNSU = ultimoNSU; + return this; + } + +} diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe/webservices/distribuicao/MDFeDistribuicaoDFeStub.java b/src/main/java/com/fincatto/documentofiscal/mdfe/webservices/distribuicao/MDFeDistribuicaoDFeStub.java new file mode 100644 index 000000000..49b35cca5 --- /dev/null +++ b/src/main/java/com/fincatto/documentofiscal/mdfe/webservices/distribuicao/MDFeDistribuicaoDFeStub.java @@ -0,0 +1,1916 @@ +/** + * MDFeDistribuicaoDFeStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis2 version: 1.7.9 Built on : Nov 16, 2018 (12:05:37 GMT) + */ +package com.fincatto.documentofiscal.mdfe.webservices.distribuicao; + +/* + * MDFeDistribuicaoDFeStub java implementation + */ +public class MDFeDistribuicaoDFeStub extends org.apache.axis2.client.Stub { + private static int counter = 0; + protected org.apache.axis2.description.AxisOperation[] _operations; + + // hashmaps to keep the fault mapping + private java.util.HashMap faultExceptionNameMap = new java.util.HashMap(); + private java.util.HashMap faultExceptionClassNameMap = new java.util.HashMap(); + private java.util.HashMap faultMessageMap = new java.util.HashMap(); + private javax.xml.namespace.QName[] opNameArray = null; + + /** + * Constructor that takes in a configContext + */ + public MDFeDistribuicaoDFeStub(org.apache.axis2.context.ConfigurationContext configurationContext, + java.lang.String targetEndpoint) throws org.apache.axis2.AxisFault { + this(configurationContext, targetEndpoint, false); + } + + /** + * Constructor that takes in a configContext and useseperate listner + */ + public MDFeDistribuicaoDFeStub(org.apache.axis2.context.ConfigurationContext configurationContext, + java.lang.String targetEndpoint, boolean useSeparateListener) throws org.apache.axis2.AxisFault { + // To populate AxisService + populateAxisService(); + populateFaults(); + + _serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext, _service); + + _serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(targetEndpoint)); + _serviceClient.getOptions().setUseSeparateListener(useSeparateListener); + + // Set the soap version + _serviceClient.getOptions() + .setSoapVersionURI(org.apache.axiom.soap.SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); + } + + /** + * Default Constructor + */ + public MDFeDistribuicaoDFeStub(org.apache.axis2.context.ConfigurationContext configurationContext) + throws org.apache.axis2.AxisFault { + this(configurationContext, "https://mdfe.svrs.rs.gov.br/ws/MDFeDistribuicaoDFe/MDFeDistribuicaoDFe.asmx"); + } + + /** + * Default Constructor + */ + public MDFeDistribuicaoDFeStub() throws org.apache.axis2.AxisFault { + this("https://mdfe.svrs.rs.gov.br/ws/MDFeDistribuicaoDFe/MDFeDistribuicaoDFe.asmx"); + } + + /** + * Constructor taking the target endpoint + */ + public MDFeDistribuicaoDFeStub(java.lang.String targetEndpoint) throws org.apache.axis2.AxisFault { + this(null, targetEndpoint); + } + + private static synchronized java.lang.String getUniqueSuffix() { + // reset the counter if it is greater than 99999 + if (counter > 99999) { + counter = 0; + } + + counter = counter + 1; + + return java.lang.Long.toString(java.lang.System.currentTimeMillis()) + "_" + counter; + } + + private void populateAxisService() throws org.apache.axis2.AxisFault { + // creating the Service with a unique name + _service = new org.apache.axis2.description.AxisService("MDFeDistribuicaoDFe" + getUniqueSuffix()); + addAnonymousOperations(); + + // creating the operations + org.apache.axis2.description.AxisOperation __operation; + + _operations = new org.apache.axis2.description.AxisOperation[1]; + + __operation = new org.apache.axis2.description.OutInAxisOperation(); + + __operation.setName(new javax.xml.namespace.QName( + "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe", "mdfeDistDFeInteresse")); + _service.addOperation(__operation); + + _operations[0] = __operation; + } + + // populates the faults + private void populateFaults() { + } + + /** + * Auto generated method signature + * + * @see com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFe#mdfeDistDFeInteresse + * @param mdfeDadosMsg + * @param mdfeCabecMsg + */ + public com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDistDFeInteresseResult mdfeDistDFeInteresse( + com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDadosMsg mdfeDadosMsg, + com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeCabecMsgE mdfeCabecMsg) + throws java.rmi.RemoteException { + org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext(); + + try { + org.apache.axis2.client.OperationClient _operationClient = _serviceClient + .createClient(_operations[0].getName()); + _operationClient.getOptions() + .setAction("http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe/mdfeDistDFeInteresse"); + _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); + + addPropertyToOperationClient(_operationClient, + org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, "&"); + + // create SOAP envelope with that payload + org.apache.axiom.soap.SOAPEnvelope env = null; + + env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), mdfeDadosMsg, + optimizeContent(new javax.xml.namespace.QName( + "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe", "mdfeDistDFeInteresse")), + new javax.xml.namespace.QName("http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe", + "mdfeDadosMsg")); + + env.build(); + + // add the children only if the parameter is not null + if (mdfeCabecMsg != null) { + org.apache.axiom.om.OMElement omElementmdfeCabecMsg = toOM(mdfeCabecMsg, + optimizeContent(new javax.xml.namespace.QName( + "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe", + "mdfeDistDFeInteresse"))); + addHeader(omElementmdfeCabecMsg, env); + } + + // adding SOAP soap_headers + _serviceClient.addHeadersToEnvelope(env); + // set the message context with that soap envelope + _messageContext.setEnvelope(env); + + // add the message contxt to the operation client + _operationClient.addMessageContext(_messageContext); + + // execute the operation client + _operationClient.execute(true); + + org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient + .getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE); + org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope(); + + java.lang.Object object = fromOM(_returnEnv.getBody().getFirstElement(), + com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDistDFeInteresseResult.class); + + return (com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDistDFeInteresseResult) object; + } catch (org.apache.axis2.AxisFault f) { + org.apache.axiom.om.OMElement faultElt = f.getDetail(); + + if (faultElt != null) { + if (faultExceptionNameMap.containsKey( + new org.apache.axis2.client.FaultMapKey(faultElt.getQName(), "mdfeDistDFeInteresse"))) { + // make the fault by reflection + try { + java.lang.String exceptionClassName = (java.lang.String) faultExceptionClassNameMap.get( + new org.apache.axis2.client.FaultMapKey(faultElt.getQName(), "mdfeDistDFeInteresse")); + java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); + java.lang.reflect.Constructor constructor = exceptionClass + .getConstructor(java.lang.String.class); + java.lang.Exception ex = (java.lang.Exception) constructor.newInstance(f.getMessage()); + + // message class + java.lang.String messageClassName = (java.lang.String) faultMessageMap.get( + new org.apache.axis2.client.FaultMapKey(faultElt.getQName(), "mdfeDistDFeInteresse")); + java.lang.Class messageClass = java.lang.Class.forName(messageClassName); + java.lang.Object messageObject = fromOM(faultElt, messageClass); + java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", + new java.lang.Class[] { messageClass }); + m.invoke(ex, new java.lang.Object[] { messageObject }); + + throw new java.rmi.RemoteException(ex.getMessage(), ex); + } catch (java.lang.ClassCastException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.ClassNotFoundException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.NoSuchMethodException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.reflect.InvocationTargetException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.IllegalAccessException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.InstantiationException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } + } else { + throw f; + } + } else { + throw f; + } + } finally { + if (_messageContext.getTransportOut() != null) { + _messageContext.getTransportOut().getSender().cleanup(_messageContext); + } + } + } + + private boolean optimizeContent(javax.xml.namespace.QName opName) { + if (opNameArray == null) { + return false; + } + + for (int i = 0; i < opNameArray.length; i++) { + if (opName.equals(opNameArray[i])) { + return true; + } + } + + return false; + } + + private org.apache.axiom.om.OMElement toOM( + com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDadosMsg param, + boolean optimizeContent) throws org.apache.axis2.AxisFault { + try { + return param.getOMElement( + com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDadosMsg.MY_QNAME, + org.apache.axiom.om.OMAbstractFactory.getOMFactory()); + } catch (org.apache.axis2.databinding.ADBException e) { + throw org.apache.axis2.AxisFault.makeFault(e); + } + } + + private org.apache.axiom.om.OMElement toOM( + com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDistDFeInteresseResult param, + boolean optimizeContent) throws org.apache.axis2.AxisFault { + try { + return param.getOMElement( + com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDistDFeInteresseResult.MY_QNAME, + org.apache.axiom.om.OMAbstractFactory.getOMFactory()); + } catch (org.apache.axis2.databinding.ADBException e) { + throw org.apache.axis2.AxisFault.makeFault(e); + } + } + + private org.apache.axiom.om.OMElement toOM( + com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeCabecMsgE param, + boolean optimizeContent) throws org.apache.axis2.AxisFault { + try { + return param.getOMElement( + com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeCabecMsgE.MY_QNAME, + org.apache.axiom.om.OMAbstractFactory.getOMFactory()); + } catch (org.apache.axis2.databinding.ADBException e) { + throw org.apache.axis2.AxisFault.makeFault(e); + } + } + + private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, + com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDadosMsg param, + boolean optimizeContent, javax.xml.namespace.QName elementQName) throws org.apache.axis2.AxisFault { + try { + org.apache.axiom.soap.SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope(); + emptyEnvelope.getBody().addChild(param.getOMElement( + com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDadosMsg.MY_QNAME, + factory)); + + return emptyEnvelope; + } catch (org.apache.axis2.databinding.ADBException e) { + throw org.apache.axis2.AxisFault.makeFault(e); + } + } + + /* methods to provide back word compatibility */ + + /** + * get the default envelope + */ + private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory) { + return factory.getDefaultEnvelope(); + } + + private java.lang.Object fromOM(org.apache.axiom.om.OMElement param, java.lang.Class type) + throws org.apache.axis2.AxisFault { + try { + if (com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeCabecMsgE.class + .equals(type)) { + return com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeCabecMsgE.Factory + .parse(param.getXMLStreamReaderWithoutCaching()); + } + + if (com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDadosMsg.class + .equals(type)) { + return com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDadosMsg.Factory + .parse(param.getXMLStreamReaderWithoutCaching()); + } + + if (com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDistDFeInteresseResult.class + .equals(type)) { + return com.fincatto.documentofiscal.mdfe.webservices.distribuicao.MDFeDistribuicaoDFeStub.MdfeDistDFeInteresseResult.Factory + .parse(param.getXMLStreamReaderWithoutCaching()); + } + } catch (java.lang.Exception e) { + throw org.apache.axis2.AxisFault.makeFault(e); + } + + return null; + } + + // https://mdfe.svrs.rs.gov.br/ws/MDFeDistribuicaoDFe/MDFeDistribuicaoDFe.asmx + public static class ExtensionMapper { + public static java.lang.Object getTypeObject(java.lang.String namespaceURI, java.lang.String typeName, + javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception { + if ("http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe".equals(namespaceURI) + && "mdfeCabecMsg".equals(typeName)) { + return MdfeCabecMsg.Factory.parse(reader); + } + + throw new org.apache.axis2.databinding.ADBException("Unsupported type " + namespaceURI + " " + typeName); + } + } + + public static class MdfeDistDFeInteresseResult implements org.apache.axis2.databinding.ADBBean { + public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName( + "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe", "mdfeDistDFeInteresseResult", "ns1"); + + /** + * field for ExtraElement + */ + protected org.apache.axiom.om.OMElement localExtraElement; + + /** + * Auto generated getter method + * + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getExtraElement() { + return localExtraElement; + } + + /** + * Auto generated setter method + * + * @param param ExtraElement + */ + public void setExtraElement(org.apache.axiom.om.OMElement param) { + this.localExtraElement = param; + } + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException { + return factory.createOMElement(new org.apache.axis2.databinding.ADBDataSource(this, MY_QNAME)); + } + + public void serialize(final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { + serialize(parentQName, xmlWriter, false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { + java.lang.String prefix = null; + java.lang.String namespace = null; + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter); + + if (serializeType) { + java.lang.String namespacePrefix = registerPrefix(xmlWriter, + "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe"); + + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) { + writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", + namespacePrefix + ":mdfeDistDFeInteresseResult", xmlWriter); + } else { + writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", + "mdfeDistDFeInteresseResult", xmlWriter); + } + } + + if (localExtraElement != null) { + localExtraElement.serialize(xmlWriter); + } else { + throw new org.apache.axis2.databinding.ADBException("extraElement cannot be null!!"); + } + + xmlWriter.writeEndElement(); + } + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if (namespace.equals("http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe")) { + return "ns1"; + } + + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + /** + * Utility method to write an element start tag. + */ + private void writeStartElement(java.lang.String prefix, java.lang.String namespace, java.lang.String localPart, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + + if (writerPrefix != null) { + xmlWriter.writeStartElement(writerPrefix, localPart, namespace); + } else { + if (namespace.length() == 0) { + prefix = ""; + } else if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, localPart, namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix, java.lang.String namespace, java.lang.String attName, + java.lang.String attValue, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + + if (writerPrefix != null) { + xmlWriter.writeAttribute(writerPrefix, namespace, attName, attValue); + } else { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + xmlWriter.writeAttribute(prefix, namespace, attName, attValue); + } + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace, java.lang.String attName, java.lang.String attValue, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + xmlWriter.writeAttribute(registerPrefix(xmlWriter, namespace), namespace, attName, attValue); + } + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + + java.lang.String attributeValue; + + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(attributePrefix, namespace, attName, attributeValue); + } + } + + /** + * method to handle Qnames + */ + private void writeQName(javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + xmlWriter.writeCharacters( + prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + if (qnames != null) { + // we have to store this data until last moment since it is not possible to + // write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + + namespaceURI = qnames[i].getNamespaceURI(); + + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + stringToWrite.append(prefix).append(":").append( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite + .append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + + xmlWriter.writeCharacters(stringToWrite.toString()); + } + } + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) + throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext(); + + while (true) { + java.lang.String uri = nsContext.getNamespaceURI(prefix); + + if ((uri == null) || (uri.length() == 0)) { + break; + } + + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + /** + * Factory class that keeps the parse method + */ + public static class Factory { + private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory + .getLog(Factory.class); + + /** + * static method to create the object Precondition: If this object is an + * element, the current or next start element starts this object and any + * intervening reader events are ignorable If this object is not an element, it + * is a complex type and the reader is at the event just after the outer start + * element Postcondition: If this object is an element, the reader is positioned + * at its end element If this object is a complex type, the reader is positioned + * at the end element of its outer element + */ + public static MdfeDistDFeInteresseResult parse(javax.xml.stream.XMLStreamReader reader) + throws java.lang.Exception { + MdfeDistDFeInteresseResult object = new MdfeDistDFeInteresseResult(); + + int event; + javax.xml.namespace.QName currentQName = null; + java.lang.String nillableValue = null; + java.lang.String prefix = ""; + java.lang.String namespaceuri = ""; + + try { + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + currentQName = reader.getName(); + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) { + java.lang.String fullTypeName = reader + .getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type"); + + if (fullTypeName != null) { + java.lang.String nsPrefix = null; + + if (fullTypeName.indexOf(":") > -1) { + nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":")); + } + + nsPrefix = (nsPrefix == null) ? "" : nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":") + 1); + + if (!"mdfeDistDFeInteresseResult".equals(type)) { + // find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + + return (MdfeDistDFeInteresseResult) ExtensionMapper.getTypeObject(nsUri, type, reader); + } + } + } + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + reader.next(); + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) { + // use the QName from the parser as the name for the builder + javax.xml.namespace.QName startQname1 = reader.getName(); + + // We need to wrap the reader so that it produces a fake START_DOCUMENT event + // this is needed by the builder classes + org.apache.axis2.databinding.utils.NamedStaxOMBuilder builder1 = new org.apache.axis2.databinding.utils.NamedStaxOMBuilder( + new org.apache.axis2.util.StreamWrapper(reader), startQname1); + object.setExtraElement(builder1.getOMElement()); + + reader.next(); + } // End of if for expected property start element + + else { + // 1 - A start element we are not expecting indicates an invalid parameter was + // passed + throw new org.apache.axis2.databinding.ADBException( + "Unexpected subelement " + reader.getName()); + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) { + // 2 - A start element we are not expecting indicates a trailing invalid + // property + throw new org.apache.axis2.databinding.ADBException( + "Unexpected subelement " + reader.getName()); + } + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + } // end of factory class + } + + public static class MdfeCabecMsgE implements org.apache.axis2.databinding.ADBBean { + public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName( + "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe", "mdfeCabecMsg", "ns1"); + + /** + * field for MdfeCabecMsg + */ + protected MdfeCabecMsg localMdfeCabecMsg; + + /** + * Auto generated getter method + * + * @return MdfeCabecMsg + */ + public MdfeCabecMsg getMdfeCabecMsg() { + return localMdfeCabecMsg; + } + + /** + * Auto generated setter method + * + * @param param MdfeCabecMsg + */ + public void setMdfeCabecMsg(MdfeCabecMsg param) { + this.localMdfeCabecMsg = param; + } + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException { + return factory.createOMElement(new org.apache.axis2.databinding.ADBDataSource(this, MY_QNAME)); + } + + public void serialize(final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { + serialize(parentQName, xmlWriter, false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { + // We can safely assume an element has only one type associated with it + if (localMdfeCabecMsg == null) { + throw new org.apache.axis2.databinding.ADBException("mdfeCabecMsg cannot be null!"); + } + + localMdfeCabecMsg.serialize(MY_QNAME, xmlWriter); + } + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if (namespace.equals("http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe")) { + return "ns1"; + } + + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + /** + * Utility method to write an element start tag. + */ + private void writeStartElement(java.lang.String prefix, java.lang.String namespace, java.lang.String localPart, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + + if (writerPrefix != null) { + xmlWriter.writeStartElement(writerPrefix, localPart, namespace); + } else { + if (namespace.length() == 0) { + prefix = ""; + } else if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, localPart, namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix, java.lang.String namespace, java.lang.String attName, + java.lang.String attValue, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + + if (writerPrefix != null) { + xmlWriter.writeAttribute(writerPrefix, namespace, attName, attValue); + } else { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + xmlWriter.writeAttribute(prefix, namespace, attName, attValue); + } + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace, java.lang.String attName, java.lang.String attValue, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + xmlWriter.writeAttribute(registerPrefix(xmlWriter, namespace), namespace, attName, attValue); + } + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + + java.lang.String attributeValue; + + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(attributePrefix, namespace, attName, attributeValue); + } + } + + /** + * method to handle Qnames + */ + private void writeQName(javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + xmlWriter.writeCharacters( + prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + if (qnames != null) { + // we have to store this data until last moment since it is not possible to + // write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + + namespaceURI = qnames[i].getNamespaceURI(); + + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + stringToWrite.append(prefix).append(":").append( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite + .append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + + xmlWriter.writeCharacters(stringToWrite.toString()); + } + } + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) + throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext(); + + while (true) { + java.lang.String uri = nsContext.getNamespaceURI(prefix); + + if ((uri == null) || (uri.length() == 0)) { + break; + } + + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + /** + * Factory class that keeps the parse method + */ + public static class Factory { + private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory + .getLog(Factory.class); + + /** + * static method to create the object Precondition: If this object is an + * element, the current or next start element starts this object and any + * intervening reader events are ignorable If this object is not an element, it + * is a complex type and the reader is at the event just after the outer start + * element Postcondition: If this object is an element, the reader is positioned + * at its end element If this object is a complex type, the reader is positioned + * at the end element of its outer element + */ + public static MdfeCabecMsgE parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception { + MdfeCabecMsgE object = new MdfeCabecMsgE(); + + int event; + javax.xml.namespace.QName currentQName = null; + java.lang.String nillableValue = null; + java.lang.String prefix = ""; + java.lang.String namespaceuri = ""; + + try { + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + currentQName = reader.getName(); + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + while (!reader.isEndElement()) { + if (reader.isStartElement()) { + if (reader.isStartElement() && new javax.xml.namespace.QName( + "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe", "mdfeCabecMsg") + .equals(reader.getName())) { + object.setMdfeCabecMsg(MdfeCabecMsg.Factory.parse(reader)); + } // End of if for expected property start element + + else { + // 3 - A start element we are not expecting indicates an invalid parameter was + // passed + throw new org.apache.axis2.databinding.ADBException( + "Unexpected subelement " + reader.getName()); + } + } else { + reader.next(); + } + } // end of while loop + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + } // end of factory class + } + + public static class MdfeDadosMsg implements org.apache.axis2.databinding.ADBBean { + public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName( + "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe", "mdfeDadosMsg", "ns1"); + + /** + * field for ExtraElement + */ + protected org.apache.axiom.om.OMElement localExtraElement; + + /** + * Auto generated getter method + * + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getExtraElement() { + return localExtraElement; + } + + /** + * Auto generated setter method + * + * @param param ExtraElement + */ + public void setExtraElement(org.apache.axiom.om.OMElement param) { + this.localExtraElement = param; + } + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException { + return factory.createOMElement(new org.apache.axis2.databinding.ADBDataSource(this, MY_QNAME)); + } + + public void serialize(final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { + serialize(parentQName, xmlWriter, false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { + java.lang.String prefix = null; + java.lang.String namespace = null; + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter); + + if (serializeType) { + java.lang.String namespacePrefix = registerPrefix(xmlWriter, + "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe"); + + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) { + writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", + namespacePrefix + ":mdfeDadosMsg", xmlWriter); + } else { + writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "mdfeDadosMsg", + xmlWriter); + } + } + + if (localExtraElement != null) { + localExtraElement.serialize(xmlWriter); + } else { + throw new org.apache.axis2.databinding.ADBException("extraElement cannot be null!!"); + } + + xmlWriter.writeEndElement(); + } + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if (namespace.equals("http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe")) { + return "ns1"; + } + + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + /** + * Utility method to write an element start tag. + */ + private void writeStartElement(java.lang.String prefix, java.lang.String namespace, java.lang.String localPart, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + + if (writerPrefix != null) { + xmlWriter.writeStartElement(writerPrefix, localPart, namespace); + } else { + if (namespace.length() == 0) { + prefix = ""; + } else if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, localPart, namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix, java.lang.String namespace, java.lang.String attName, + java.lang.String attValue, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + + if (writerPrefix != null) { + xmlWriter.writeAttribute(writerPrefix, namespace, attName, attValue); + } else { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + xmlWriter.writeAttribute(prefix, namespace, attName, attValue); + } + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace, java.lang.String attName, java.lang.String attValue, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + xmlWriter.writeAttribute(registerPrefix(xmlWriter, namespace), namespace, attName, attValue); + } + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + + java.lang.String attributeValue; + + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(attributePrefix, namespace, attName, attributeValue); + } + } + + /** + * method to handle Qnames + */ + private void writeQName(javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + xmlWriter.writeCharacters( + prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + if (qnames != null) { + // we have to store this data until last moment since it is not possible to + // write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + + namespaceURI = qnames[i].getNamespaceURI(); + + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + stringToWrite.append(prefix).append(":").append( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite + .append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + + xmlWriter.writeCharacters(stringToWrite.toString()); + } + } + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) + throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext(); + + while (true) { + java.lang.String uri = nsContext.getNamespaceURI(prefix); + + if ((uri == null) || (uri.length() == 0)) { + break; + } + + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + /** + * Factory class that keeps the parse method + */ + public static class Factory { + private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory + .getLog(Factory.class); + + /** + * static method to create the object Precondition: If this object is an + * element, the current or next start element starts this object and any + * intervening reader events are ignorable If this object is not an element, it + * is a complex type and the reader is at the event just after the outer start + * element Postcondition: If this object is an element, the reader is positioned + * at its end element If this object is a complex type, the reader is positioned + * at the end element of its outer element + */ + public static MdfeDadosMsg parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception { + MdfeDadosMsg object = new MdfeDadosMsg(); + + int event; + javax.xml.namespace.QName currentQName = null; + java.lang.String nillableValue = null; + java.lang.String prefix = ""; + java.lang.String namespaceuri = ""; + + try { + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + currentQName = reader.getName(); + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) { + java.lang.String fullTypeName = reader + .getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type"); + + if (fullTypeName != null) { + java.lang.String nsPrefix = null; + + if (fullTypeName.indexOf(":") > -1) { + nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":")); + } + + nsPrefix = (nsPrefix == null) ? "" : nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":") + 1); + + if (!"mdfeDadosMsg".equals(type)) { + // find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + + return (MdfeDadosMsg) ExtensionMapper.getTypeObject(nsUri, type, reader); + } + } + } + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + reader.next(); + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) { + // use the QName from the parser as the name for the builder + javax.xml.namespace.QName startQname1 = reader.getName(); + + // We need to wrap the reader so that it produces a fake START_DOCUMENT event + // this is needed by the builder classes + org.apache.axis2.databinding.utils.NamedStaxOMBuilder builder1 = new org.apache.axis2.databinding.utils.NamedStaxOMBuilder( + new org.apache.axis2.util.StreamWrapper(reader), startQname1); + object.setExtraElement(builder1.getOMElement()); + + reader.next(); + } // End of if for expected property start element + + else { + // 1 - A start element we are not expecting indicates an invalid parameter was + // passed + throw new org.apache.axis2.databinding.ADBException( + "Unexpected subelement " + reader.getName()); + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) { + // 2 - A start element we are not expecting indicates a trailing invalid + // property + throw new org.apache.axis2.databinding.ADBException( + "Unexpected subelement " + reader.getName()); + } + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + } // end of factory class + } + + public static class MdfeCabecMsg implements org.apache.axis2.databinding.ADBBean { + /* + * This type was generated from the piece of schema that had name = mdfeCabecMsg + * Namespace URI = http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe + * Namespace Prefix = ns1 + */ + + /** + * field for CUF + */ + protected java.lang.String localCUF; + + /* + * This tracker boolean wil be used to detect whether the user called the set + * method for this attribute. It will be used to determine whether to include + * this field in the serialized XML + */ + protected boolean localCUFTracker = false; + + /** + * field for VersaoDados + */ + protected java.lang.String localVersaoDados; + + /* + * This tracker boolean wil be used to detect whether the user called the set + * method for this attribute. It will be used to determine whether to include + * this field in the serialized XML + */ + protected boolean localVersaoDadosTracker = false; + + /** + * field for ExtraAttributes This was an Attribute! This was an Array! + */ + protected org.apache.axiom.om.OMAttribute[] localExtraAttributes; + + public boolean isCUFSpecified() { + return localCUFTracker; + } + + /** + * Auto generated getter method + * + * @return java.lang.String + */ + public java.lang.String getCUF() { + return localCUF; + } + + /** + * Auto generated setter method + * + * @param param CUF + */ + public void setCUF(java.lang.String param) { + localCUFTracker = param != null; + + this.localCUF = param; + } + + public boolean isVersaoDadosSpecified() { + return localVersaoDadosTracker; + } + + /** + * Auto generated getter method + * + * @return java.lang.String + */ + public java.lang.String getVersaoDados() { + return localVersaoDados; + } + + /** + * Auto generated setter method + * + * @param param VersaoDados + */ + public void setVersaoDados(java.lang.String param) { + localVersaoDadosTracker = param != null; + + this.localVersaoDados = param; + } + + /** + * Auto generated getter method + * + * @return org.apache.axiom.om.OMAttribute[] + */ + public org.apache.axiom.om.OMAttribute[] getExtraAttributes() { + return localExtraAttributes; + } + + /** + * validate the array for ExtraAttributes + */ + protected void validateExtraAttributes(org.apache.axiom.om.OMAttribute[] param) { + if ((param != null) && (param.length > 1)) { + throw new java.lang.RuntimeException("Input values do not follow defined XSD restrictions"); + } + + if ((param != null) && (param.length < 1)) { + throw new java.lang.RuntimeException("Input values do not follow defined XSD restrictions"); + } + } + + /** + * Auto generated setter method + * + * @param param ExtraAttributes + */ + public void setExtraAttributes(org.apache.axiom.om.OMAttribute[] param) { + validateExtraAttributes(param); + + this.localExtraAttributes = param; + } + + /** + * Auto generated add method for the array for convenience + * + * @param param org.apache.axiom.om.OMAttribute + */ + public void addExtraAttributes(org.apache.axiom.om.OMAttribute param) { + if (localExtraAttributes == null) { + localExtraAttributes = new org.apache.axiom.om.OMAttribute[] {}; + } + + java.util.List list = org.apache.axis2.databinding.utils.ConverterUtil.toList(localExtraAttributes); + list.add(param); + this.localExtraAttributes = (org.apache.axiom.om.OMAttribute[]) list + .toArray(new org.apache.axiom.om.OMAttribute[list.size()]); + } + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException { + return factory.createOMElement(new org.apache.axis2.databinding.ADBDataSource(this, parentQName)); + } + + public void serialize(final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { + serialize(parentQName, xmlWriter, false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { + java.lang.String prefix = null; + java.lang.String namespace = null; + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter); + + if (serializeType) { + java.lang.String namespacePrefix = registerPrefix(xmlWriter, + "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe"); + + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) { + writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", + namespacePrefix + ":mdfeCabecMsg", xmlWriter); + } else { + writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "mdfeCabecMsg", + xmlWriter); + } + } + + if (localExtraAttributes != null) { + for (int i = 0; i < localExtraAttributes.length; i++) { + writeAttribute(localExtraAttributes[i].getNamespace().getName(), + localExtraAttributes[i].getLocalName(), localExtraAttributes[i].getAttributeValue(), + xmlWriter); + } + } + + if (localCUFTracker) { + namespace = "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe"; + writeStartElement(null, namespace, "cUF", xmlWriter); + + if (localCUF == null) { + // write the nil attribute + throw new org.apache.axis2.databinding.ADBException("cUF cannot be null!!"); + } else { + xmlWriter.writeCharacters(localCUF); + } + + xmlWriter.writeEndElement(); + } + + if (localVersaoDadosTracker) { + namespace = "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe"; + writeStartElement(null, namespace, "versaoDados", xmlWriter); + + if (localVersaoDados == null) { + // write the nil attribute + throw new org.apache.axis2.databinding.ADBException("versaoDados cannot be null!!"); + } else { + xmlWriter.writeCharacters(localVersaoDados); + } + + xmlWriter.writeEndElement(); + } + + xmlWriter.writeEndElement(); + } + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if (namespace.equals("http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe")) { + return "ns1"; + } + + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + /** + * Utility method to write an element start tag. + */ + private void writeStartElement(java.lang.String prefix, java.lang.String namespace, java.lang.String localPart, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + + if (writerPrefix != null) { + xmlWriter.writeStartElement(writerPrefix, localPart, namespace); + } else { + if (namespace.length() == 0) { + prefix = ""; + } else if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, localPart, namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix, java.lang.String namespace, java.lang.String attName, + java.lang.String attValue, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + + if (writerPrefix != null) { + xmlWriter.writeAttribute(writerPrefix, namespace, attName, attValue); + } else { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + xmlWriter.writeAttribute(prefix, namespace, attName, attValue); + } + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace, java.lang.String attName, java.lang.String attValue, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + xmlWriter.writeAttribute(registerPrefix(xmlWriter, namespace), namespace, attName, attValue); + } + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + + java.lang.String attributeValue; + + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(attributePrefix, namespace, attName, attributeValue); + } + } + + /** + * method to handle Qnames + */ + private void writeQName(javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + xmlWriter.writeCharacters( + prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, javax.xml.stream.XMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException { + if (qnames != null) { + // we have to store this data until last moment since it is not possible to + // write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + + namespaceURI = qnames[i].getNamespaceURI(); + + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + stringToWrite.append(prefix).append(":").append( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite + .append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + + xmlWriter.writeCharacters(stringToWrite.toString()); + } + } + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) + throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext(); + + while (true) { + java.lang.String uri = nsContext.getNamespaceURI(prefix); + + if ((uri == null) || (uri.length() == 0)) { + break; + } + + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + /** + * Factory class that keeps the parse method + */ + public static class Factory { + private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory + .getLog(Factory.class); + + /** + * static method to create the object Precondition: If this object is an + * element, the current or next start element starts this object and any + * intervening reader events are ignorable If this object is not an element, it + * is a complex type and the reader is at the event just after the outer start + * element Postcondition: If this object is an element, the reader is positioned + * at its end element If this object is a complex type, the reader is positioned + * at the end element of its outer element + */ + public static MdfeCabecMsg parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception { + MdfeCabecMsg object = new MdfeCabecMsg(); + + int event; + javax.xml.namespace.QName currentQName = null; + java.lang.String nillableValue = null; + java.lang.String prefix = ""; + java.lang.String namespaceuri = ""; + + try { + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + currentQName = reader.getName(); + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) { + java.lang.String fullTypeName = reader + .getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type"); + + if (fullTypeName != null) { + java.lang.String nsPrefix = null; + + if (fullTypeName.indexOf(":") > -1) { + nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":")); + } + + nsPrefix = (nsPrefix == null) ? "" : nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":") + 1); + + if (!"mdfeCabecMsg".equals(type)) { + // find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + + return (MdfeCabecMsg) ExtensionMapper.getTypeObject(nsUri, type, reader); + } + } + } + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + // now run through all any or extra attributes + // which were not reflected until now + for (int i = 0; i < reader.getAttributeCount(); i++) { + if (!handledAttributes.contains(reader.getAttributeLocalName(i))) { + // this is an anyAttribute and we create + // an OMAttribute for this + org.apache.axiom.om.OMFactory factory = org.apache.axiom.om.OMAbstractFactory + .getOMFactory(); + org.apache.axiom.om.OMAttribute attr = factory.createOMAttribute( + reader.getAttributeLocalName(i), + factory.createOMNamespace(reader.getAttributeNamespace(i), + reader.getAttributePrefix(i)), + reader.getAttributeValue(i)); + + // and add it to the extra attributes + object.addExtraAttributes(attr); + } + } + + reader.next(); + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName( + "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe", "cUF") + .equals(reader.getName())) { + nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "nil"); + + if ("true".equals(nillableValue) || "1".equals(nillableValue)) { + throw new org.apache.axis2.databinding.ADBException( + "The element: " + "cUF" + " cannot be null"); + } + + java.lang.String content = reader.getElementText(); + + object.setCUF(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + } // End of if for expected property start element + + else { + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName( + "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeDistribuicaoDFe", "versaoDados") + .equals(reader.getName())) { + nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "nil"); + + if ("true".equals(nillableValue) || "1".equals(nillableValue)) { + throw new org.apache.axis2.databinding.ADBException( + "The element: " + "versaoDados" + " cannot be null"); + } + + java.lang.String content = reader.getElementText(); + + object.setVersaoDados( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + } // End of if for expected property start element + + else { + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) { + // 2 - A start element we are not expecting indicates a trailing invalid + // property + throw new org.apache.axis2.databinding.ADBException( + "Unexpected subelement " + reader.getName()); + } + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + } // end of factory class + } +} diff --git a/src/main/java/com/fincatto/documentofiscal/mdfe/webservices/distribuicao/WSDistribuicaoMDFe.java b/src/main/java/com/fincatto/documentofiscal/mdfe/webservices/distribuicao/WSDistribuicaoMDFe.java new file mode 100644 index 000000000..a5d6d360e --- /dev/null +++ b/src/main/java/com/fincatto/documentofiscal/mdfe/webservices/distribuicao/WSDistribuicaoMDFe.java @@ -0,0 +1,99 @@ +package com.fincatto.documentofiscal.mdfe.webservices.distribuicao; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.rmi.RemoteException; +import java.util.Base64; +import java.util.zip.GZIPInputStream; + +import javax.xml.stream.XMLStreamException; + +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.util.AXIOMUtil; +import org.apache.commons.lang3.StringUtils; + +import com.fincatto.documentofiscal.DFUnidadeFederativa; +import com.fincatto.documentofiscal.mdfe.classes.distribuicao.MDFeDistribuicaoConsultaNSU; +import com.fincatto.documentofiscal.mdfe.classes.distribuicao.MDFeDistribuicaoInt; +import com.fincatto.documentofiscal.mdfe.classes.distribuicao.MDFeDistribuicaoIntRetorno; +import com.fincatto.documentofiscal.mdfe.classes.distribuicao.MDFeDistribuicaoNSU; +import com.fincatto.documentofiscal.mdfe3.MDFeConfig; +import com.fincatto.documentofiscal.mdfe3.classes.MDFAutorizador3; +import com.fincatto.documentofiscal.validadores.DFXMLValidador; + +public class WSDistribuicaoMDFe { + + private final MDFeConfig config; + + public WSDistribuicaoMDFe(final MDFeConfig config) { + this.config = config; + } + + public MDFeDistribuicaoIntRetorno consultar(final String cpfOuCnpj, final DFUnidadeFederativa uf, final String nsu, final String ultNsu) throws Exception { + try { + String xmlEnvio = this.gerarMDFeDistribuicaoInt(cpfOuCnpj, nsu, ultNsu).toString(); + + DFXMLValidador.validaDistribuicaoMDFe(xmlEnvio); + + final OMElement ome = AXIOMUtil.stringToOM(xmlEnvio); + + final MDFeDistribuicaoDFeStub.MdfeDadosMsg mdfeDadosMsg = new MDFeDistribuicaoDFeStub.MdfeDadosMsg(); + mdfeDadosMsg.setExtraElement(ome); + + final MDFeDistribuicaoDFeStub.MdfeCabecMsg mdfeCabecMsg = new MDFeDistribuicaoDFeStub.MdfeCabecMsg(); + mdfeCabecMsg.setCUF(uf.getCodigo()); + mdfeCabecMsg.setVersaoDados("1.00"); + + final MDFeDistribuicaoDFeStub.MdfeCabecMsgE mdfeCabecMsgE = new MDFeDistribuicaoDFeStub.MdfeCabecMsgE(); + mdfeCabecMsgE.setMdfeCabecMsg(mdfeCabecMsg); + + final MDFeDistribuicaoDFeStub stub = new MDFeDistribuicaoDFeStub(MDFAutorizador3.RS.getMDFeDistribuicao(config.getAmbiente())); + final MDFeDistribuicaoDFeStub.MdfeDistDFeInteresseResult result = stub.mdfeDistDFeInteresse(mdfeDadosMsg, mdfeCabecMsgE); + + return this.config.getPersister().read(MDFeDistribuicaoIntRetorno.class, result.getExtraElement().toString()); + } catch (RemoteException | XMLStreamException e) { + throw new Exception(e.getMessage()); + } + } + + private MDFeDistribuicaoInt gerarMDFeDistribuicaoInt(final String cpfOuCnpj, final String nsu, + final String ultNsu) { + final MDFeDistribuicaoInt distDFeInt = new MDFeDistribuicaoInt(); + distDFeInt.setVersao("1.00"); + distDFeInt.setAmbiente(this.config.getAmbiente()); + + if (cpfOuCnpj.length() == 11) { + distDFeInt.setCpf(cpfOuCnpj); + } else { + distDFeInt.setCnpj(cpfOuCnpj); + } + + if (StringUtils.isNotBlank(ultNsu)) { + distDFeInt.setDistribuicao(new MDFeDistribuicaoNSU().setUltimoNSU(ultNsu)); + } else { + distDFeInt.setConsulta(new MDFeDistribuicaoConsultaNSU().setNsu(nsu)); + } + return distDFeInt; + } + + public static String decodeGZipToXml(final String conteudoEncode) throws Exception { + if (conteudoEncode == null || conteudoEncode.length() == 0) { + return ""; + } + final byte[] conteudo = Base64.getDecoder().decode(conteudoEncode);// java 8 + // final byte[] conteudo = + // DatatypeConverter.parseBase64Binary(conteudoEncode);//java 7 + try (GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(conteudo))) { + try (BufferedReader bf = new BufferedReader(new InputStreamReader(gis, StandardCharsets.UTF_8))) { + StringBuilder outStr = new StringBuilder(); + String line; + while ((line = bf.readLine()) != null) { + outStr.append(line); + } + return outStr.toString(); + } + } + } +} diff --git a/src/main/resources/schemas/PL_MDFeDistDFe_100/distDFeInt_v1.00.xsd b/src/main/resources/schemas/PL_MDFeDistDFe_100/distDFeInt_v1.00.xsd new file mode 100644 index 000000000..8ab39e94c --- /dev/null +++ b/src/main/resources/schemas/PL_MDFeDistDFe_100/distDFeInt_v1.00.xsd @@ -0,0 +1,63 @@ + + + + + + Schema de pedido de distribuição de DF-e de interesse + + + + + + Identificação do Ambiente: +1 - Produção +2 - Homologação + + + + + + CNPJ do interessado no DF-e + + + + + CPF do interessado no DF-e + + + + + + + Grupo para distribuir DF-e de interesse + + + + + + Último NSU recebido pelo ator. Caso seja informado com zero, ou com um NSU muito antigo, a consulta retornará unicamente as informações resumidas e documentos fiscais eletrônicos que tenham sido recepcionados pelo Ambiente Nacional nos últimos 3 meses. + + + + + + + + Grupo para consultar um DF-e a partir de um NSU específico + + + + + + Número Sequencial Único. Geralmente esta consulta será utilizada quando identificado pelo interessado um NSU faltante. O Web Service retornará o documento ou informará que o NSU não existe no Ambiente Nacional. Assim, esta consulta fechará a lacuna do NSU identificado como faltante. + + + + + + + + + + + diff --git a/src/main/resources/schemas/PL_MDFeDistDFe_100/retDistDFeInt_v1.00.xsd b/src/main/resources/schemas/PL_MDFeDistDFe_100/retDistDFeInt_v1.00.xsd new file mode 100644 index 000000000..81ec6c59c --- /dev/null +++ b/src/main/resources/schemas/PL_MDFeDistDFe_100/retDistDFeInt_v1.00.xsd @@ -0,0 +1,87 @@ + + + + + + Schema do resultado do pedido de distribuição de DF-e de interesse + + + + + + Identificação do Ambiente: +1 - Produção +2 - Homologação + + + + + Versão do Web Service MDFeDistribuicaoDFe + + + + + Código do status de processamento da requisição + + + + + Descrição literal do status do processamento da requisição + + + + + Data e Hora de processamento da requisição no formato AAAA-MM-DDTHH:MM:SS + + + + + + + + + + + Último NSU pesquisado no Ambiente Nacional. Se for o caso, o solicitante pode continuar a consulta a partir deste NSU para obter novos resultados. + + + + + Maior NSU existente no Ambiente Nacional para o CNPJ/CPF informado + + + + + Conjunto de informações resumidas e documentos fiscais eletrônicos de interesse da pessoa ou empresa. + + + + + + Informação resumida ou documento fiscal eletrônico de interesse da pessoa ou empresa. O conteúdo desta tag estará compactado no padrão gZip. O tipo do campo é base64Binary. + + + + + + + NSU do documento fiscal + + + + + Identificação do Schema XML que será utilizado para validar o XML existente no conteúdo da tag docZip. Vai identificar o tipo do documento e sua versão. Exemplos: procMDFe_v2.00.xsd, procEventoMDFe_v2.00.xsd + + + + + + + + + + + + + + diff --git a/src/main/resources/schemas/PL_MDFeDistDFe_100/tiposDistDFe_v1.00.xsd b/src/main/resources/schemas/PL_MDFeDistDFe_100/tiposDistDFe_v1.00.xsd new file mode 100644 index 000000000..dd8d5c252 --- /dev/null +++ b/src/main/resources/schemas/PL_MDFeDistDFe_100/tiposDistDFe_v1.00.xsd @@ -0,0 +1,198 @@ + + + + + Tipo número sequencial único + + + + + + + + Tipo quantidade de NSU + + + + + + + + + Tipo Versão dos leiautes do Web Service MDFeDistribuicaoDFe + + + + + + + + + Tipo Ambiente + + + + + + + + + + Tipo Código da UF da tabela do IBGE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Tipo Código de orgão (UF da tabela do IBGE + 90 RFB) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Tipo Número do CNPJ + + + + + + + + + + Tipo Número do CPF + + + + + + + + + + Tipo Versão do Aplicativo + + + + + + + + + Tipo Código da Mensagem enviada + + + + + + + + + + Tipo Motivo + + + + + + + + + Tipo string genérico + + + + + + + + + Tipo Número do Protocolo de Status + + + + + + + + + + Tipo Inscrição Estadual do Emitente // alterado EM 24/10/08 para aceitar ISENTO + + + + + + + + + + Tipo Decimal com 15 dígitos, sendo 13 de corpo e 2 decimais + + + + + + + diff --git a/src/main/resources/schemas/PL_MDFeDistDFe_100/tiposGeralMDFe_v1.00.xsd b/src/main/resources/schemas/PL_MDFeDistDFe_100/tiposGeralMDFe_v1.00.xsd new file mode 100644 index 000000000..57d98c0cf --- /dev/null +++ b/src/main/resources/schemas/PL_MDFeDistDFe_100/tiposGeralMDFe_v1.00.xsd @@ -0,0 +1,606 @@ + + + + + Tipo Código da UF da tabela do IBGE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Tipo Código do Município da tabela do IBGE + + + + + + + + + Tipo Código de orgão (UF da tabela do IBGE + 90 SUFRAMA + 91 RFB + 92 BRId) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Tipo Código da UF da tabela do IBGE + 99 para Exterior + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Tipo Chave do Conhecimento de Transporte Eletrônico + + + + + + + + + + Tipo Chave da Nota Fiscal Eletrônica + + + + + + + + + + Tipo Chave de Manifesto de Documentos Fiscais Eletrônico + + + + + + + + + + Tipo Segundo Codigo Barra + + + + + + + + Tipo Número do Protocolo de Status + + + + + + + + + Tipo Número do Recibo do envio de lote de NF-e + + + + + + + + + Tipo Código da Mensagem enviada + + + + + + + + + Tipo Número do CNPJ + + + + + + + + + Tipo Número do CNPJ tamanho varíavel (3-14) + + + + + + + + + Tipo Número do CNPJ Opcional + + + + + + + + + Tipo Número do CPF + + + + + + + + + Tipo Número do CPF de tamanho variável (3-11) + + + + + + + + + Tipo Decimal com 5 dígitos, sendo 3 de corpo e 2 decimais + + + + + + + + + Tipo Decimal com 6 dígitos, sendo 3 de corpo e 3 decimais + + + + + + + + + Tipo Decimal com 5 dígitos, sendo 3 de corpo e 2 decimais, utilizado em tags opcionais + + + + + + + + + Tipo Decimal com 11 dígitos, sendo 8 de corpo e 3 decimais + + + + + + + + + Tipo Decimal com 11 dígitos, sendo 8 de corpo e 3 decimais utilizado em tags opcionais + + + + + + + + + Tipo Decimal com 12 dígitos, sendo 8 de corpo e 4decimais + + + + + + + + + Tipo Decimal com 12 dígitos, sendo 8 de corpo e 4 decimais, utilizado em tags opcionais + + + + + + + + + Tipo Decimal com 15 dígitos, sendo 9 de corpo e 6 decimais, utilizado em tags opcionais + + + + + + + + + Tipo Decimal com 15 dígitos, sendo 11 de corpo e 4 decimais + + + + + + + + + Tipo Decimal com 15 dígitos, sendo 11 de corpo e 4 decimais, utilizado em tags opcionais + + + + + + + + + Tipo Decimal com 15 dígitos, sendo 12 de corpo e 3 decimais + + + + + + + + + Tipo Decimal com 15 dígitos, sendo 12 de corpo e 3 decimais, utilizado em tags opcionais + + + + + + + + + Tipo Decimal com 16 dígitos, sendo 12 de corpo e 4 decimais + + + + + + + + + Tipo Decimal com 16 dígitos, sendo 12 de corpo e 4 decimais, utilizado em tags opcionais + + + + + + + + + Tipo Decimal com 15 dígitos, sendo 13 de corpo e 2 decimais + + + + + + + + + Tipo Decimal com 15 dígitos, sendo 13 de corpo e 2 decimais, utilizado em tags opcionais + + + + + + + + + Tipo Inscrição Estadual do Destinatário + + + + + + + + + Tipo Modelo Manifesto de Documento Fiscal Eletrônico + + + + + + + + + Tipo Inscrição Estadual do Emitente + + + + + + + + + Tipo Número do Documento Fiscal + + + + + + + + + Tipo Série do Documento Fiscal + + + + + + + + + Tipo Sigla da UF + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Tipo Ambiente + + + + + + + + + + Tipo Emitente + + + + + + + + + + Tipo Versão do Aplicativo + + + + + + + + + Tipo Motivo + + + + + + + + + Tipo Justificativa + + + + + + + + + Tipo Serviço solicitado + + + + + + Tipo ano + + + + + + + + + Tipo temp médio em segundos + + + + + + + + + Tipo string genérico + + + + + + + + + Tipo data AAAA-MM-DD + + + + + + + + + Coordenada geográfica Latitude + + + + + + + + Coordenada geográfica Longitude + + + + + + + + Tipo da Unidade de Transporte + + + + + + + + + + + + + + + Tipo da Unidade de Carga + + + + + + + + + + + + Tipo número sequencial único do AN + + + + + + + + Tipo Placa + + + + + + + diff --git a/src/main/resources/schemas/PL_MDFeDistDFe_100/xmldsig-core-schema_v1.01.xsd b/src/main/resources/schemas/PL_MDFeDistDFe_100/xmldsig-core-schema_v1.01.xsd new file mode 100644 index 000000000..f7dc8dc6e --- /dev/null +++ b/src/main/resources/schemas/PL_MDFeDistDFe_100/xmldsig-core-schema_v1.01.xsd @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file