Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Colaboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #11  
Antiguo 22-10-2024
Avatar de bmfranky
bmfranky bmfranky is offline
Miembro
 
Registrado: may 2024
Ubicación: Gandia, Valencia
Posts: 862
Poder: 3
bmfranky Va por buen camino
Cita:
Empezado por marccabra Ver Mensaje
SI pudieras explicar como haces esto sería genial. Justo ahora obtengo errores al deserializar la respuesta y me vendría bien poderla ver en crudo.

Gracias
Cita:
Empezado por [email protected] Ver Mensaje
Me apunto a la explicacion

Hola, he implementado esta funcion , si la de aeat da error de serializacion o otro no interpretable uso esta.
Código:
       /// <summary>
        /// Envio del registro de la factura a la aeat
        /// </summary>
        /// <param name="facAPresentar">Registro creado con las funciones de la aeat.</param>
        /// <param name="action">Accion a realizar por defecto registro alta</param>
        /// <returns>Devuelve la respuesta completa de la aeat</returns>
        public string consultaAEAT(RegFactuSistemaFacturacion facAPresentar,string action = "RegistroAlta")
        {
            XmlSerializer serializaFactura = new XmlSerializer(typeof(RegFactuSistemaFacturacion));
            string facXml = "";
            using (var xmlw = new StringWriter())
            {
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;
                settings.Encoding = Encoding.UTF8;

                using (XmlWriter writter = XmlWriter.Create(xmlw, settings))
                {
                    serializaFactura.Serialize(writter, facAPresentar);
                    facXml = xmlw.ToString();
                }

            }
            facXml = facXml.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">  <soapenv:Header /> <soapenv:Body >");
            facXml = facXml.Replace("<RegFactuSistemaFacturacion xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">", "<RegFactuSistemaFacturacion xmlns=\"https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroLR.xsd\">");
            //facXml = facXml.Replace("</SistemaInformatico>", "</SistemaInformatico> \r\n <FechaHoraHusoGenRegistro xmlns=\"https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroInformacion.xsd\">" + timeStamp +"</FechaHoraHusoGenRegistro>");
            facXml = facXml + " </soapenv:Body> </soapenv:Envelope > ";
            ////////////////////////// <----- Prueba extraccion sin serializar 


            XmlDocument doc = new XmlDocument();

            doc.LoadXml(facXml.Replace("utf-16", "utf-8"));
            HttpWebRequest webRequest = CreateWebRequest("https://prewww1.aeat.es/wlpl/TIKE-CONT/ws/SistemaFacturacion/VerifactuSOAP", action);
            System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            X509Certificate2 certificate = new X509Certificate2(Program.certificado, Program.passcertificado); //requiere estas variables globalescontienen el certificado y su clave
            var tiempo = certificate.SubjectName;
            if (certificate == null)
                throw new ArgumentNullException(
                    "Certificate is null. Maybe serial number in configuration was wrong.");

            if (certificate.NotAfter < DateTime.Now)
                throw new ArgumentNullException(
                  $"Certificate is out of date. NotAfter: {certificate.NotAfter}.");

            webRequest.ClientCertificates.Add(certificate);

            using (Stream stream = webRequest.GetRequestStream())
            {
                doc.Save(stream);
            }

            HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();

            string statusDescription = response.StatusDescription;

            Stream dataStream = response.GetResponseStream();

            string responseFromServer;

            using (StreamReader reader = new StreamReader(dataStream))
            {
                responseFromServer = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
                response.Close();
            }

            return responseFromServer;

            //retorno = client.RegFactuSistemaFacturacion(facAPresentar);
        }
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Hijo de Informáticos gluglu Humor 3 13-03-2007 11:05:35
Adictos informaticos ... Trigger Humor 2 11-10-2004 12:18:32
Nosotros los Informáticos Trigger Humor 1 10-10-2004 14:58:09
Patrón de los Informáticos. obiwuan Varios 20 10-09-2003 14:44:54
Chistes Informaticos jhonny Humor 2 11-08-2003 21:59:09


La franja horaria es GMT +2. Ahora son las 07:52:49.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi