public virtual async Task <string> TransmitirAsync(UrlSefaz sefazUrl, XmlDocument envelope) { logger.LogInformation($"Iniciando transmissão Sefaz [{sefazUrl.Url}]"); HttpWebRequest webRequest = SoapEnvelopeFabrica.CriarWebRequest(sefazUrl.Url, "application/soap+xml;charset=utf-8"); Soap.InserirSoapEnvelopeWebRequest(envelope, webRequest); webRequest.ClientCertificates.Add(ObterCertificado.Obter(configuracao.ConfigCertificado)); IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null); string soapResult; using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult)) { using StreamReader rd = new StreamReader(webResponse.GetResponseStream()); soapResult = await rd.ReadToEndAsync(); } logger.LogInformation($"Encerrando transmissão Sefaz"); return(soapResult); }