Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: nova estrutura base de comunicação, mantendo o default #1495

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DFe.Wsdl/Common/ConfiguracaoServicoWSDL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
public static class ConfiguracaoServicoWSDL
{
public static bool ValidarCertificadoDoServidorNetCore { get; set; }
public static IRequestSefaz RequestSefaz { get; set; }

static ConfiguracaoServicoWSDL()
{
ValidarCertificadoDoServidorNetCore = true;
RequestSefaz = new RequestSefazDefault();
}
}
}
18 changes: 18 additions & 0 deletions DFe.Wsdl/Common/IRequestSefaz.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using System.Xml;
using CTe.CTeOSDocumento.Common;

namespace DFe.Wsdl.Common
{
public interface IRequestSefaz
{
XmlDocument SerealizeDocument<T>(T soapEnvelope);

Task<string> SendRequestAsync(XmlDocument xmlEnvelop, X509Certificate2 certificadoDigital, string url,
int timeOut, TipoEvento? tipoEvento = null, string actionUrn = "");

string SendRequest(XmlDocument xmlEnvelop, X509Certificate2 certificadoDigital, string url, int timeOut,
TipoEvento? tipoEvento = null, string actionUrn = "");
}
}
49 changes: 49 additions & 0 deletions DFe.Wsdl/Common/RequestSefazDefault.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.IO;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
using CTe.CTeOSDocumento.Common;
using CTe.CTeOSDocumento.Soap;
using DFe.Http.Ext;

namespace DFe.Wsdl.Common
{
public class RequestSefazDefault : IRequestSefaz
{
/// <summary>
/// Serializa a estrutura do envelope contida no objeto para um XmlDocument.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="soapEnvelope"></param>
/// <returns></returns>
public XmlDocument SerealizeDocument<T>(T soapEnvelope)
{
return ConfiguracaoServicoWSDL.RequestSefaz.SerealizeDocument(soapEnvelope);
}

/// <summary>
/// Cria e envia a requisição HttpClient, retornando a resposta obtida do WebService.
/// </summary>
/// <param name="xmlEnvelop"></param>
/// <param name="certificadoDigital"></param>
/// <param name="url"></param>
/// <param name="timeOut"></param>
/// <param name="tipoEvento"></param>
/// <returns></returns>
public async Task<string> SendRequestAsync(XmlDocument xmlEnvelop, X509Certificate2 certificadoDigital, string url, int timeOut, TipoEvento? tipoEvento = null, string actionUrn = "")
{
return await ConfiguracaoServicoWSDL.RequestSefaz.SendRequestAsync(xmlEnvelop, certificadoDigital, url, timeOut,
tipoEvento, actionUrn);
}

public string SendRequest(XmlDocument xmlEnvelop, X509Certificate2 certificadoDigital, string url, int timeOut, TipoEvento? tipoEvento = null, string actionUrn = "")
{
return ConfiguracaoServicoWSDL.RequestSefaz.SendRequest(xmlEnvelop, certificadoDigital, url, timeOut,
tipoEvento, actionUrn);
}
}
}
Loading