Как отправить XML-файл в nfe с помощью C#? независимо от того, завершилось ли оно успешно, не удалось или находится в ожидании вот так
public async Task EnviarNFeAsync(string xmlAssinado, string url, X509Certificate2 certificado)
{
var handler = new HttpClientHandler();
handler.ClientCertificates.Add(certificado);
using (var client = new HttpClient(handler))
{
HttpContent content = new StringContent(xmlAssinado, Encoding.UTF8, "application/xml");
HttpResponseMessage response = await client.PostAsync(url, content);
string resposta = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
MessageBox.Show("foi");
Console.WriteLine("NFe enviada com sucesso!");
Console.WriteLine("Resposta: " + resposta);
}
else
{
MessageBox.Show("erro");
Console.WriteLine("Erro ao enviar NFe.");
Console.WriteLine("Status Code: " + response.StatusCode);
Console.WriteLine("Resposta: " + resposta);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... webservice