예제 #1
0
        public EetClient(Certificate certificate, EetEnvironment environment = EetEnvironment.Production, TimeSpan?httpTimeout = null, EetLogger logger = null)
        {
            var effectiveTimeout = httpTimeout ?? TimeSpan.FromSeconds(2);

            EetSoapClient = new EetSoapClient(certificate, environment, effectiveTimeout, logger);
            Logger        = logger;
            EetSoapClient.HttpRequestFinished  += (sender, args) => HttpRequestFinished?.Invoke(this, args);
            EetSoapClient.XmlMessageSerialized += (sender, args) => XmlMessageSerialized?.Invoke(this, args);
        }
예제 #2
0
 public SoapClient(Uri endpointUri, Certificate certificate, TimeSpan httpTimeout, SignAlgorithm signAlgorithm = SignAlgorithm.Sha256, EetLogger logger = null)
 {
     HttpClient     = new SoapHttpClient(endpointUri, httpTimeout, logger);
     Certificate    = certificate;
     SignAlgorithm  = signAlgorithm;
     XmlManipulator = new XmlManipulator();
     Logger         = logger;
     HttpClient.HttpRequestFinished += (sender, args) => HttpRequestFinished?.Invoke(this, args);
 }
예제 #3
0
        public CfdiRecoveryClient(Certificate certificate, TimeSpan?httpTimeout = null, Logger logger = null)
        {
            var effectiveTimeout = httpTimeout ?? TimeSpan.FromSeconds(2);

            SatSoapClient = new SatSoapClient(certificate, effectiveTimeout, logger);
            Logger        = logger;
            SatSoapClient.HttpRequestFinished  += (sender, args) => HttpRequestFinished?.Invoke(this, args);
            SatSoapClient.XmlMessageSerialized += (sender, args) => XmlMessageSerialized?.Invoke(this, args);
        }
예제 #4
0
        public SatSoapClient(Certificate certificate, TimeSpan httpTimeout, Logger logger)
        {
            var endpointUri = new Uri("https://cfdidescargamasivasolicitud.clouda.sat.gob.mx/Autenticacion/Autenticacion.svc");

            SoapClient = new SoapClient(endpointUri, certificate, httpTimeout, SignAlgorithm.Sha1);
            Logger     = logger;
            SoapClient.HttpRequestFinished  += (sender, args) => HttpRequestFinished?.Invoke(this, args);
            SoapClient.XmlMessageSerialized += (sender, args) => XmlMessageSerialized?.Invoke(this, args);
        }
예제 #5
0
        public EetSoapClient(Certificate certificate, EetEnvironment environment, TimeSpan httpTimeout, EetLogger logger = null)
        {
            Environment = environment;
            var subdomain   = environment == EetEnvironment.Production ? "prod" : "pg";
            var endpointUri = new Uri($"https://{subdomain}.eet.cz:443/eet/services/EETServiceSOAP/v3");

            SoapClient = new SoapClient(endpointUri, certificate, httpTimeout, SignAlgorithm.Sha256, logger);
            Logger     = logger;
            SoapClient.HttpRequestFinished  += (sender, args) => HttpRequestFinished?.Invoke(this, args);
            SoapClient.XmlMessageSerialized += (sender, args) => XmlMessageSerialized?.Invoke(this, args);
        }
예제 #6
0
        public Client(X509Certificate certificate, Environment environment, TimeSpan httpTimeout)
        {
            var domain = environment.Match(
                Environment.Test, _ => "www7.aeat.es",
                Environment.Production, _ => "www1.agenciatributaria.gob.es"
                );
            var endpointUri = new Uri($"https://{domain}/wlpl/SSII-FACT/ws/fe/SiiFactFEV1SOAP");

            SoapClient = new SoapClient(endpointUri, certificate, httpTimeout);
            SoapClient.HttpRequestFinished  += (sender, args) => HttpRequestFinished?.Invoke(this, args);
            SoapClient.XmlMessageSerialized += (sender, args) => XmlMessageSerialized?.Invoke(this, args);
        }
예제 #7
0
        private async Task <string> GetResponseAsync(string body)
        {
            var requestContent = new StringContent(body, Encoding.UTF8, "application/x-www-form-urlencoded");

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            using (var response = await HttpClient.PostAsync(EndpointUri, requestContent))
            {
                var result = await response.Content.ReadAsStringAsync();

                stopwatch.Stop();
                var duration = stopwatch.ElapsedMilliseconds;
                HttpRequestFinished?.Invoke(this, new HttpRequestFinishedEventArgs(result, duration));

                return(result);
            }
        }
예제 #8
0
        public async Task <string> SendAsync(string body, string operation)
        {
            HttpClient.DefaultRequestHeaders.Add("SOAPAction", operation);

            var requestContent = new StringContent(body, Encoding.UTF8, "application/x-www-form-urlencoded");

            Logger?.Debug("Starting HTTP request.", new { HttpRequestBody = body });

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            using (var response = await HttpClient.PostAsync(EndpointUri, requestContent))
            {
                var result = await response.Content.ReadAsStringAsync();

                stopwatch.Stop();
                var duration = stopwatch.ElapsedMilliseconds;
                Logger?.Info($"HTTP request finished in {stopwatch.ElapsedMilliseconds}ms.", new { HttpRequestDuration = duration });
                HttpRequestFinished?.Invoke(this, new HttpRequestFinishedEventArgs(duration));

                return(result);
            }
        }