24 lines
826 B
C#
24 lines
826 B
C#
using System.Security.Cryptography.X509Certificates;
|
|
using System.Text;
|
|
|
|
public class HttpClientService
|
|
{
|
|
private readonly HttpClient _client;
|
|
|
|
public HttpClientService()
|
|
{
|
|
var handler = new HttpClientHandler
|
|
{
|
|
ClientCertificates = { new X509Certificate2("X:\\Back\\APP Smart\\Certificado\\cert_ssl.pfx", "appsmart") }
|
|
};
|
|
_client = new HttpClient(handler) { DefaultRequestHeaders = { { "SOAPAction", "listarPLD" } } };
|
|
}
|
|
|
|
public async Task<string> EnviarRequisicaoAsync(string xmlRequest)
|
|
{
|
|
var content = new StringContent(xmlRequest, Encoding.UTF8, "application/json");
|
|
var response = await _client.PostAsync("https://servicos.ccee.org.br:443/ws/prec/PLDBSv1", content);
|
|
return await response.Content.ReadAsStringAsync();
|
|
}
|
|
}
|