Created
May 15, 2015 13:52
-
-
Save Pierry/2d266a9b204fff3a999c to your computer and use it in GitHub Desktop.
des
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
public XmlDocument CriarArquivoEnvio() | |
{ | |
var consultaServico = new StatusServicoEnvio("1.00", 2); | |
var serializer = new XmlSerializer(typeof (StatusServicoEnvio)); | |
using (var stream = new StreamWriter(PathEnvio)) | |
{ | |
serializer.Serialize(stream, consultaServico); | |
} | |
var doc = new XmlDocument(); | |
doc.Load(PathEnvio); | |
doc.InnerXml = doc.InnerXml.Replace(@"<?xml version=""1.0"" encoding=""utf-8""?>", ""); | |
doc.InnerXml = | |
doc.InnerXml.Replace( | |
@"xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""", | |
@"xmlns=""http://www.portalfiscal.inf.br/mdfe"""); | |
return doc; | |
} | |
public void CriarArquivoRetorno(string xml) | |
{ | |
var docRetorno = new XmlDocument(); | |
var xmlTratado = xml.Replace(@" xmlns=""http://www.portalfiscal.inf.br/mdfe""", ""); | |
docRetorno.LoadXml(@"<retConsStatServMDFe>" + xmlTratado + "</retConsStatServMDFe>"); | |
var xmlWriter = new XmlTextWriter(PathRetorno, null); | |
xmlWriter.Formatting = Formatting.Indented; | |
docRetorno.Save(xmlWriter); | |
xmlWriter.Close(); | |
} | |
public StatusServicoResposta Deserializar() | |
{ | |
var deserialier = new XmlSerializer(typeof (StatusServicoResposta)); | |
var reader = new StreamReader(PathRetorno); | |
var obj = deserialier.Deserialize(reader); | |
var resposta = (StatusServicoResposta) obj; | |
reader.Close(); | |
return resposta; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment