-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementa o Envio Sincrono do MDFe.
- Loading branch information
1 parent
65ac1fe
commit 24243a1
Showing
10 changed files
with
180 additions
and
4 deletions.
There are no files selected for viewing
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
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
64 changes: 64 additions & 0 deletions
64
MDFe.Classes/Retorno/MDFeRetRecepcao/Sincrono/MDFeRetMDFe.cs
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,64 @@ | ||
using DFe.Classes.Entidades; | ||
using DFe.Classes.Extensoes; | ||
using DFe.Classes.Flags; | ||
using DFe.Utils; | ||
using System; | ||
using System.Xml.Serialization; | ||
|
||
namespace MDFe.Classes.Retorno.MDFeRetRecepcao.Sincrono | ||
{ | ||
[Serializable] | ||
[XmlRoot(Namespace = "http://www.portalfiscal.inf.br/mdfe", | ||
ElementName = "retMDFe")] | ||
public class MDFeRetMDFe: RetornoBase | ||
{ | ||
[XmlAttribute(AttributeName = "versao")] | ||
public string Versao { get; set; } | ||
|
||
[XmlElement(ElementName = "tpAmb")] | ||
public TipoAmbiente TpAmb { get; set; } | ||
|
||
[XmlElement(ElementName = "verAplic")] | ||
public string VerAplic { get; set; } | ||
|
||
[XmlElement(ElementName = "nRec")] | ||
public string NRec { get; set; } | ||
|
||
[XmlElement(ElementName = "cStat")] | ||
public short CStat { get; set; } | ||
|
||
[XmlElement(ElementName = "xMotivo")] | ||
public string XMotivo { get; set; } | ||
|
||
[XmlIgnore] | ||
public Estado CUF { get; set; } | ||
|
||
[XmlElement(ElementName = "cUF")] | ||
public string CUFProxy | ||
{ | ||
get | ||
{ | ||
return CUF.GetCodigoIbgeEmString(); | ||
} | ||
set { CUF = CUF.CodigoIbgeParaEstado(value); } | ||
} | ||
|
||
[XmlElement(ElementName = "protMDFe")] | ||
public MDFeProtMDFe ProtMdFe { get; set; } | ||
|
||
public static MDFeRetMDFe LoadXml(string xml) | ||
{ | ||
var retorno = FuncoesXml.XmlStringParaClasse<MDFeRetMDFe>(xml); | ||
retorno.RetornoXmlString = xml; | ||
|
||
return retorno; | ||
} | ||
public static MDFeRetMDFe LoadXml(string xml, Informacoes.MDFe mdfe) | ||
{ | ||
var retorno = LoadXml(xml); | ||
retorno.EnvioXmlString = FuncoesXml.ClasseParaXmlString(mdfe); | ||
|
||
return retorno; | ||
} | ||
} | ||
} |
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
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
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,65 @@ | ||
using CTe.CTeOSDocumento.Common; | ||
using DFe.Utils; | ||
using System; | ||
using System.Net; | ||
using System.Xml; | ||
using System.Xml.Serialization; | ||
|
||
namespace MDFe.Wsdl.MDFeRecepcao.Sincrono | ||
{ | ||
public class MDFeRecepcaoSinc | ||
{ | ||
private readonly SoapEnvelope soapEnvelope; | ||
|
||
//Configurações do WSDL para estabelecimento da comunicação | ||
private readonly WsdlConfiguracao configuracao; | ||
|
||
/// <summary> | ||
/// Cria o cabeçalho do envelope a ser enviado e atribui as configurações do WSDL. | ||
/// </summary> | ||
/// <param name="configuracao"></param> | ||
public MDFeRecepcaoSinc(WsdlConfiguracao configuracao) | ||
{ | ||
if (configuracao == null) | ||
throw new ArgumentNullException(); | ||
|
||
this.configuracao = configuracao; | ||
soapEnvelope = new SoapEnvelope(); | ||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; | ||
} | ||
|
||
/// <summary> | ||
/// Encapsula os dados da requisição no envelope por meio da serialização das partes e realiza a requisção ao Web Service. | ||
/// </summary> | ||
/// <param name="mdfeDadosMsg"></param> | ||
/// <returns>XmlNode</returns> | ||
public XmlNode mdfeRecepcao(XmlNode mdfeDadosMsg) | ||
{ | ||
soapEnvelope.body = new ResponseBody<string> | ||
{ | ||
mdfeDadosMsg = Convert.ToBase64String(Compressao.Zip(mdfeDadosMsg.OuterXml)) | ||
}; | ||
return RequestBuilderAndSender.Execute(soapEnvelope, configuracao, TipoEvento.MDFeRecepcaoSinc, "retMDFe"); | ||
} | ||
|
||
/// <summary> | ||
/// Classe base para a serialização no formato do envelope SOAP. | ||
/// </summary> | ||
[XmlRoot(ElementName = "Envelope", Namespace = "http://www.w3.org/2003/05/soap-envelope")] | ||
public class SoapEnvelope : CommonSoapEnvelope | ||
{ | ||
|
||
[XmlElement(ElementName = "Body", Namespace = "http://www.w3.org/2003/05/soap-envelope")] | ||
public ResponseBody<string> body { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// Classe para o corpo do Envelope SOAP | ||
/// </summary> | ||
public class ResponseBody<T> : CommonResponseBody | ||
{ | ||
[XmlElement(Namespace = "http://www.portalfiscal.inf.br/mdfe/wsdl/MDFeRecepcaoSinc")] | ||
public T mdfeDadosMsg { get; set; } | ||
} | ||
} | ||
} |