-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from ismaellawrenz/Cte-simplificado
Implementação do CTe simplificado
- Loading branch information
Showing
83 changed files
with
87,442 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/main/java/br/com/swconsultoria/cte/EnvioCteSimp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package br.com.swconsultoria.cte; | ||
|
||
import br.com.swconsultoria.cte.dom.ConfiguracoesCte; | ||
import br.com.swconsultoria.cte.dom.enuns.AssinaturaEnum; | ||
import br.com.swconsultoria.cte.dom.enuns.ServicosEnum; | ||
import br.com.swconsultoria.cte.exception.CteException; | ||
import br.com.swconsultoria.cte.schema_400.cteSimp.TCTeSimp; | ||
import br.com.swconsultoria.cte.schema_400.cteSimp.TRetCTeSimp; | ||
import br.com.swconsultoria.cte.util.WebServiceCteUtil; | ||
import br.com.swconsultoria.cte.util.XmlCteUtil; | ||
import br.com.swconsultoria.cte.wsdl.cte_recepcao_simp.CTeRecepcaoSimpV4Stub; | ||
import lombok.extern.java.Log; | ||
|
||
import javax.xml.bind.JAXBException; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Classe Responsavel por Enviar o Cte simplificado. | ||
* | ||
* @author Ismael Luan Lawrenz | ||
*/ | ||
@Log | ||
class EnvioCteSimp { | ||
|
||
private EnvioCteSimp() { | ||
} | ||
|
||
/** | ||
* Metodo para Montar a CTE simplificado | ||
* | ||
* @param config | ||
* @param cte | ||
* @param valida | ||
* @return TCTeSimp | ||
* @throws CteException | ||
*/ | ||
static TCTeSimp montaCteSimp(ConfiguracoesCte config, TCTeSimp cte, boolean valida) throws CteException { | ||
try { | ||
|
||
/** | ||
* Cria o xml | ||
*/ | ||
String xml = XmlCteUtil.objectToXml(cte); | ||
|
||
/** | ||
* Assina o Xml | ||
*/ | ||
xml = Assinar.assinaCte(config, xml, AssinaturaEnum.CTE_SIMP); | ||
log.info("[XML-ASSINADO]: " + xml); | ||
|
||
/** | ||
* Valida o Xml caso sejá selecionado True | ||
*/ | ||
if (valida) { | ||
new Validar().validaXml(config, xml, ServicosEnum.ENVIO_CTE_SIMP); | ||
} | ||
|
||
return XmlCteUtil.xmlToObject(xml, TCTeSimp.class); | ||
|
||
} catch (Exception e) { | ||
throw new CteException(e); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Metodo para Enviar a CTE simplificado | ||
* | ||
* @param config | ||
* @param cte | ||
* @return TRetCTeSimp | ||
* @throws CteException | ||
*/ | ||
static TRetCTeSimp enviaCteSimp(ConfiguracoesCte config, TCTeSimp cte) throws CteException { | ||
|
||
try { | ||
|
||
String xml = XmlCteUtil.objectToXml(cte); | ||
|
||
log.info("[XML-ENVIO]: " + xml); | ||
|
||
CTeRecepcaoSimpV4Stub.CteDadosMsg dadosMsg = new CTeRecepcaoSimpV4Stub.CteDadosMsg(); | ||
dadosMsg.setCteDadosMsg(XmlCteUtil.xmlToGZip(xml)); | ||
|
||
CTeRecepcaoSimpV4Stub stub = new CTeRecepcaoSimpV4Stub( | ||
WebServiceCteUtil.getUrl(config, ServicosEnum.ENVIO_CTE_SIMP)); | ||
CTeRecepcaoSimpV4Stub.CteRecepcaoSimpResult result = stub.cteRecepcaoSimp(dadosMsg); | ||
|
||
TRetCTeSimp retCte = XmlCteUtil.xmlToObject(result.getExtraElement().toString(), | ||
TRetCTeSimp.class); | ||
|
||
log.info("[XML-RETORNO]: " + XmlCteUtil.objectToXml(retCte)); | ||
return retCte; | ||
|
||
} catch (IOException | JAXBException e) { | ||
throw new CteException("Erro ao enviar CTe", e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/main/java/br/com/swconsultoria/cte/schema_400/cteSimp/KeyInfoType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
|
||
|
||
|
||
package br.com.swconsultoria.cte.schema_400.cteSimp; | ||
|
||
import javax.xml.bind.annotation.*; | ||
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; | ||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; | ||
|
||
|
||
/** | ||
* <p>Java class for KeyInfoType complex type. | ||
* | ||
* <p>The following schema fragment specifies the expected content contained within this class. | ||
* | ||
* <pre> | ||
* <complexType name="KeyInfoType"> | ||
* <complexContent> | ||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> | ||
* <sequence> | ||
* <element name="X509Data" type="{http://www.w3.org/2000/09/xmldsig#}X509DataType"/> | ||
* </sequence> | ||
* <attribute name="Id" type="{http://www.w3.org/2001/XMLSchema}ID" /> | ||
* </restriction> | ||
* </complexContent> | ||
* </complexType> | ||
* </pre> | ||
* | ||
* | ||
*/ | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
@XmlType(name = "KeyInfoType", namespace = "http://www.w3.org/2000/09/xmldsig#", propOrder = { | ||
"x509Data" | ||
}) | ||
public class KeyInfoType { | ||
|
||
@XmlElement(name = "X509Data", required = true) | ||
protected X509DataType x509Data; | ||
@XmlAttribute(name = "Id") | ||
@XmlJavaTypeAdapter(CollapsedStringAdapter.class) | ||
@XmlID | ||
@XmlSchemaType(name = "ID") | ||
protected String id; | ||
|
||
/** | ||
* Gets the value of the x509Data property. | ||
* | ||
* @return | ||
* possible object is | ||
* {@link X509DataType } | ||
* | ||
*/ | ||
public X509DataType getX509Data() { | ||
return x509Data; | ||
} | ||
|
||
/** | ||
* Sets the value of the x509Data property. | ||
* | ||
* @param value | ||
* allowed object is | ||
* {@link X509DataType } | ||
* | ||
*/ | ||
public void setX509Data(X509DataType value) { | ||
this.x509Data = value; | ||
} | ||
|
||
/** | ||
* Gets the value of the id property. | ||
* | ||
* @return | ||
* possible object is | ||
* {@link String } | ||
* | ||
*/ | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
/** | ||
* Sets the value of the id property. | ||
* | ||
* @param value | ||
* allowed object is | ||
* {@link String } | ||
* | ||
*/ | ||
public void setId(String value) { | ||
this.id = value; | ||
} | ||
|
||
} |
Oops, something went wrong.