Skip to content

Commit

Permalink
Ajustes para melhor funcionamento do Validador (MDFe) e do SoapUtils (#…
Browse files Browse the repository at this point in the history
…1304)

Co-authored-by: William de Quadros Moura <wmoura@braspag.com.br>
  • Loading branch information
williamoura and William de Quadros Moura authored Nov 11, 2021
1 parent d9b9fb0 commit bb59b02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
24 changes: 12 additions & 12 deletions Shared.DFe.Wsdl/Common/SoapUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ public async Task<string> SendRequestAsync(XmlDocument xmlEnvelop, X509Certifica
streamWriter.Write(xmlSoap, 0, Encoding.UTF8.GetBytes(xmlSoap).Length);
streamWriter.Close();

var webResponse = httpWr.GetResponse();
var respStream = webResponse.GetResponseStream();
StreamReader streamReader = new StreamReader(respStream);

string xmlRetorno = streamReader.ReadToEnd();
return await Task.FromResult(xmlRetorno);
using (HttpWebResponse httpResponse = (HttpWebResponse)httpWr.GetResponse())
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
string xmlRetorno = streamReader.ReadToEnd();
return await Task.FromResult(xmlRetorno);
}
}

public string SendRequest(XmlDocument xmlEnvelop, X509Certificate2 certificadoDigital, string url, int timeOut, TipoEvento? tipoEvento = null, string actionUrn = "")
Expand Down Expand Up @@ -125,12 +125,12 @@ public string SendRequest(XmlDocument xmlEnvelop, X509Certificate2 certificadoDi
streamWriter.Write(xmlSoap, 0, Encoding.UTF8.GetBytes(xmlSoap).Length);
streamWriter.Close();

var webResponse = httpWr.GetResponse();
var respStream = webResponse.GetResponseStream();
StreamReader streamReader = new StreamReader(respStream);

string xmlRetorno = streamReader.ReadToEnd();
return xmlRetorno;
using (HttpWebResponse httpResponse = (HttpWebResponse)httpWr.GetResponse())
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
string xmlRetorno = streamReader.ReadToEnd();
return xmlRetorno;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion Shared.MDFe.Utils/Validacao/Validador.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
/* http://www.zeusautomacao.com.br/ */
/* Rua Comendador Francisco josé da Cunha, 111 - Itabaiana - SE - 49500-000 */
/********************************************************************************/
using MDFe.Utils.Configuracoes;
using System;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using MDFe.Utils.Configuracoes;

namespace MDFe.Utils.Validacao
{
Expand All @@ -54,6 +54,8 @@ public static void Valida(string xml, string schema)

// Carrega o arquivo de esquema
var schemas = new XmlSchemaSet();
schemas.XmlResolver = new XmlUrlResolver();

cfg.Schemas = schemas;
// Quando carregar o eschema, especificar o namespace que ele valida
// e a localização do arquivo
Expand Down

0 comments on commit bb59b02

Please sign in to comment.