private void Executar <TDocument>(string metodo, DFeDocument <TDocument> request) where TDocument : class { var saveOptions = ACBr.Net.DFe.Core.Common.DFeSaveOptions.DisableFormatting | ACBr.Net.DFe.Core.Common.DFeSaveOptions.OmitDeclaration | ACBr.Net.DFe.Core.Common.DFeSaveOptions.RemoveSpaces; string xml = request.GetXml(saveOptions).ToString(); XmlEnvio = xml; XmlResposta = string.Empty; var _timeout = TimeSpan.FromMilliseconds(Timeout); using (var client = new RequestServiceClient(Ambiente, _timeout)) { try { XmlResposta = client.Execute(metodo, xml); XmlEnvio = client.XmlEnvio; } finally { XmlEnvio = client.XmlEnvio; if (SalvarXmls) { string path = Path.Combine(PathXmls, $"{metodo}Request_{DateTime.Now:yyyy-MM-dd_HHmmss}.xml"); File.WriteAllText(path, XmlEnvio); path = Path.Combine(PathXmls, $"{metodo}Response_{DateTime.Now:yyyy-MM-dd_HHmmss}.xml"); File.WriteAllText(path, XmlResposta); } } } }
protected RespostaBase(string xmlEnvio, string xmlRetorno, string envelopeSoap, string respostaWs, bool loadRetorno = true) { XmlEnvio = xmlEnvio; XmlRetorno = xmlRetorno; EnvelopeSoap = envelopeSoap; RetornoWS = respostaWs; if (typeof(DFeDocument <T>).IsAssignableFrom(typeof(T)) && loadRetorno) { Resultado = DFeDocument <T> .Load(xmlRetorno, Encoding.UTF8); } }