Esempio n. 1
0
        public string GenerateSoapRequestEnvelopeXmlContent(DescargaRequest descargaRequest, X509Certificate2 certificate)
        {
            var xmlDocument = new XmlDocument();

            var envelopElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.S11Prefix, "Envelope", CfdiDescargaMasivaNamespaces.S11NamespaceUrl);

            envelopElement.SetAttribute($"xmlns:{CfdiDescargaMasivaNamespaces.S11Prefix}", CfdiDescargaMasivaNamespaces.S11NamespaceUrl);
            envelopElement.SetAttribute($"xmlns:{CfdiDescargaMasivaNamespaces.DesPrefix}", CfdiDescargaMasivaNamespaces.DesNamespaceUrl);
            envelopElement.SetAttribute($"xmlns:{CfdiDescargaMasivaNamespaces.DsPrefix}", CfdiDescargaMasivaNamespaces.DsNamespaceUrl);
            xmlDocument.AppendChild(envelopElement);

            var headerElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.S11Prefix, "Header", CfdiDescargaMasivaNamespaces.S11NamespaceUrl);

            envelopElement.AppendChild(headerElement);

            var bodyElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.S11Prefix, "Body", CfdiDescargaMasivaNamespaces.S11NamespaceUrl);

            envelopElement.AppendChild(bodyElement);

            var peticionDescargaMasivaTercerosEntradaElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.DesPrefix, "PeticionDescargaMasivaTercerosEntrada", CfdiDescargaMasivaNamespaces.DesNamespaceUrl);

            bodyElement.AppendChild(peticionDescargaMasivaTercerosEntradaElement);

            var peticionDescargaElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.DesPrefix, "peticionDescarga", CfdiDescargaMasivaNamespaces.DesNamespaceUrl);

            peticionDescargaElement.SetAttribute("IdPaquete", descargaRequest.PackageId);
            peticionDescargaElement.SetAttribute("RfcSolicitante", descargaRequest.RequestingRfc);

            var signatureElement = SignedXmlHelper.SignRequest(peticionDescargaElement, certificate);

            peticionDescargaElement.AppendChild(signatureElement);
            peticionDescargaMasivaTercerosEntradaElement.AppendChild(peticionDescargaElement);

            return(xmlDocument.OuterXml);
        }
Esempio n. 2
0
        public string GenerateSoapRequestEnvelopeXmlContent(VerificacionRequest verificacionRequest, X509Certificate2 certificate)
        {
            var xmlDocument = new XmlDocument();

            var envelopElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.S11Prefix, "Envelope", CfdiDescargaMasivaNamespaces.S11NamespaceUrl);

            envelopElement.SetAttribute($"xmlns:{CfdiDescargaMasivaNamespaces.S11Prefix}", CfdiDescargaMasivaNamespaces.S11NamespaceUrl);
            envelopElement.SetAttribute($"xmlns:{CfdiDescargaMasivaNamespaces.DesPrefix}", CfdiDescargaMasivaNamespaces.DesNamespaceUrl);
            envelopElement.SetAttribute($"xmlns:{CfdiDescargaMasivaNamespaces.DsPrefix}", CfdiDescargaMasivaNamespaces.DsNamespaceUrl);
            xmlDocument.AppendChild(envelopElement);

            var headerElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.S11Prefix, "Header", CfdiDescargaMasivaNamespaces.S11NamespaceUrl);

            envelopElement.AppendChild(headerElement);

            var bodyElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.S11Prefix, "Body", CfdiDescargaMasivaNamespaces.S11NamespaceUrl);

            envelopElement.AppendChild(bodyElement);

            var verificaSolicitudDescargaElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.DesPrefix, "VerificaSolicitudDescarga", CfdiDescargaMasivaNamespaces.DesNamespaceUrl);

            bodyElement.AppendChild(verificaSolicitudDescargaElement);

            var solicitudElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.DesPrefix, "solicitud", CfdiDescargaMasivaNamespaces.DesNamespaceUrl);

            solicitudElement.SetAttribute("IdSolicitud", verificacionRequest.RequestId);
            solicitudElement.SetAttribute("RfcSolicitante", verificacionRequest.RequestingRfc);

            var signatureElement = SignedXmlHelper.SignRequest(solicitudElement, certificate);

            solicitudElement.AppendChild(signatureElement);
            verificaSolicitudDescargaElement.AppendChild(solicitudElement);

            return(xmlDocument.OuterXml);
        }
Esempio n. 3
0
        public static string GenerateSoapRequestEnvelopeXmlContent(SolicitudRequest solicitudRequest, X509Certificate2 certificate)
        {
            var xmlDocument = new XmlDocument();

            var envelopElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.S11Prefix, "Envelope", CfdiDescargaMasivaNamespaces.S11NamespaceUrl);

            envelopElement.SetAttribute($"xmlns:{CfdiDescargaMasivaNamespaces.S11Prefix}", CfdiDescargaMasivaNamespaces.S11NamespaceUrl);
            envelopElement.SetAttribute($"xmlns:{CfdiDescargaMasivaNamespaces.DesPrefix}", CfdiDescargaMasivaNamespaces.DesNamespaceUrl);
            envelopElement.SetAttribute($"xmlns:{CfdiDescargaMasivaNamespaces.DsPrefix}", CfdiDescargaMasivaNamespaces.DsNamespaceUrl);
            xmlDocument.AppendChild(envelopElement);

            var headerElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.S11Prefix, "Header", CfdiDescargaMasivaNamespaces.S11NamespaceUrl);

            envelopElement.AppendChild(headerElement);

            var bodyElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.S11Prefix, "Body", CfdiDescargaMasivaNamespaces.S11NamespaceUrl);

            envelopElement.AppendChild(bodyElement);

            var solicitaDescargaElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.DesPrefix, "SolicitaDescarga", CfdiDescargaMasivaNamespaces.DesNamespaceUrl);

            bodyElement.AppendChild(solicitaDescargaElement);

            var solicitudElement = xmlDocument.CreateElement(CfdiDescargaMasivaNamespaces.DesPrefix, "solicitud", CfdiDescargaMasivaNamespaces.DesNamespaceUrl);

            solicitudElement.SetAttribute("FechaInicial", solicitudRequest.StartDate.ToSoapStartDateString());
            solicitudElement.SetAttribute("FechaFinal", solicitudRequest.EndDate.ToSoapEndDateString());
            solicitudElement.SetAttribute("RfcEmisor", solicitudRequest.SenderRfc);
            solicitudElement.SetAttribute("RfcReceptor", solicitudRequest.RecipientRfc);
            solicitudElement.SetAttribute("RfcSolicitante", solicitudRequest.RequestingRfc);
            solicitudElement.SetAttribute("TipoSolicitud", solicitudRequest.RequestType.Name);

            var signatureElement = SignedXmlHelper.SignRequest(solicitudElement, certificate);

            solicitudElement.AppendChild(signatureElement);
            solicitaDescargaElement.AppendChild(solicitudElement);

            return(xmlDocument.OuterXml);
        }