Adriano Serighelli 460598c6b5 Código funcional.
Separação em camadas.
Utilização de estimativa para horas faltantes (entre 9 e 11 registros).
2025-10-02 17:46:48 -03:00

28 lines
1006 B
C#

using System.Xml.Linq;
namespace Infrastructure
{
public static class SoapHelper
{
public static void VerificarRespostaSOAP(string responseXml)
{
var doc = XDocument.Parse(responseXml);
XNamespace env = "http://schemas.xmlsoap.org/soap/envelope/";
XNamespace tns = "http://xmlns.energia.org.br/FM/v2";
var fault = doc.Descendants(env + "Fault").FirstOrDefault();
if (fault != null)
{
string faultCode = fault.Element("faultcode")?.Value ?? "";
string faultString = fault.Element("faultstring")?.Value ?? "";
var detail = fault.Element("detail")?.Descendants().First();
string errorCode = detail?.Element(tns + "errorCode")?.Value ?? "";
string message = detail?.Element(tns + "message")?.Value ?? "";
throw new SoapFaultException(faultCode, faultString, errorCode, message);
}
}
}
}