Crear SolicitaDescarga de los servicios web de descarga masiva del SAT

Todo lo que no cabe en los demas foros........
jc_charlymx
Mensajes: 40
Registrado: Vie Feb 04, 2011 10:10 pm

Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT

Mensajepor jc_charlymx » Mié Oct 31, 2018 9:53 pm

Buen dia

El horario que manejan es el UTC (Tiempo Universal Coordinado)

https://www.worldtimeserver.com/hora-exacta-UTC.aspx

la mayoria de los frameworks tienen una función nativa que la devuelve.

Saludos

s3cr3to
Mensajes: 501
Registrado: Mar Dic 28, 2010 2:12 pm

Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT

Mensajepor s3cr3to » Mié Oct 31, 2018 10:45 pm

Quizá esto es lo que ocupas DADO:
Display UTC time in Delphi. De ahí y por allá hice este ejemplo:

Código: Seleccionar todo

program localtime2UTC;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils
  , WinApi.Windows
  , System.DateUtils
  ;

function CurrentLocalBias: TDateTime;
const
  MinsInDay = 1440;
var
  TZInfo: TTimeZoneInformation;
begin
  //Get the between UTC and time for this locale and convert
  //to TDateTime by dividing by MinsInDay
  //NB: If local time is ahead of UTC, bias is negative
  case GetTimeZoneInformation(TZInfo) of
    TIME_ZONE_ID_DAYLIGHT:
      Result := (TZInfo.Bias + TZInfo.DaylightBias) / MinsInDay;
    TIME_ZONE_ID_STANDARD:
      Result := (TZInfo.Bias + TZInfo.StandardBias) / MinsInDay;
    TIME_ZONE_ID_UNKNOWN:
      Result := TZInfo.Bias / MinsInDay;
  else
   Result := TZInfo.Bias / MinsInDay;
  end;
end;

function UTCTimeNow: TDateTime;
begin
  //UTC time = local time + Bias + Standard/Daylight bias
  Result := Now + CurrentLocalBias;
end;


function GetTimeZone: string;
var
  TimeZone: TTimeZoneInformation;
begin
  GetTimeZoneInformation(TimeZone);
  Result := 'GMT ' + IntToStr(TimeZone.Bias div -60);
end;

function LocalToUTC(LocalTime: TDateTime): TDateTime;
var TimeZoneInformation: TTimeZoneInformation;
    Bias: integer;
begin
 Bias := 0;

 case GetTimeZoneInformation(TimeZoneInformation) of
  TIME_ZONE_ID_STANDARD: Bias := TimeZoneInformation.Bias + TimeZoneInformation.StandardBias;
  TIME_ZONE_ID_DAYLIGHT: Bias := TimeZoneInformation.Bias + TimeZoneInformation.DaylightBias;
 end;

 result := LocalTime + (Bias * OneMinute);
end;

var
  tdt : TDateTime;
begin
  try
    { TODO -oUser -cConsole Main : Insert code here }
    writeln (GetTimeZone);
    tdt := LocalToUTC(now);
    Writeln(FormatDateTime('c',tdt));
    Writeln(FormatDateTime('c',UTCTimeNow));
    readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Y este otro (con unos comentarios muy interesantes):
How to convert Local time to UTC time in Delphi XE2? and how to convert it back from UTC to local time?

...
A word of warning. Do not expect the attempt to account for daylight savings at the time being converted to be 100% accurate. It is simply impossible to achieve that. At least without a time machine. And that's just considering times in the future. Even times in the past are complex. Raymond Chen discusses the issue here: Why Daylight Savings Time is nonintuitive.

David Heffernan


Esa última nota es interesante:
Why Daylight Savings Time is nonintuitive
... One reason is that it means that FileTimeToLocalFileTime and LocalFileTimeToFileTime would no longer be inverses of each other. If you had a local time during the "limbo hour" during the cutover from standard time to daylight time, it would have no corresponding UTC time because there was no such thing as 2:30am local time. (The clock jumped from 2am to 3am.) Similarly, a local time of 2:30am during the cutover from daylight time back to standard time would have two corresponding UTC times.

Another reason is that the laws regarding daylight savings time are in constant flux. For example, if the year in the example above was 1977 instead of 2000, the conversion would have been correct because the United States was running on year-round Daylight Savings Time due to the energy crisis. Of course, this information isn't encoded anywhere in the TIME_ZONE_INFORMATION structure. Similarly, during World War 2, the United States went on DST all year round. And between 1945 and 1966, the DST rules varied from region to region.

DST rules are in flux even today. The DST cutover dates in Israel are decided on a year-by-year basis by the Knesset. As a result, there is no deterministic formula for the day, and therefore no way to know it ahead of time. ...


Desprecio con las tripas el cambio de horario! :x

Avatar de Usuario
Dado
Mensajes: 15824
Registrado: Mar Jul 06, 2010 8:56 pm

Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT

Mensajepor Dado » Jue Nov 01, 2018 12:08 am

gracias s3cr3to, estudiandole encontre una forma mas simple de obtener la hora UTC de "Hoy/ahorita"

Código: Seleccionar todo

function NowUTC : TDateTime;
var SystemTime: TSystemTime;
begin
   GetSystemTime(SystemTime);
   Result := SystemTimeToDateTime(SystemTime);
end;


Hice pruebas cambiando la fecha y la hora de mi compu, para adelante, para atras y resulto positivo en todos los casos

Mañana (mmmm, hoy?) hago pruebas ya con el web service de la descarga masiva, pa'ver que panchos hace.
ADDENDAS? VALIDACION? CODIGO PARA PROGRAMAR TU PROPIA SOLUCION? TODO LO TENEMOS EN WWW.VALIDACFD.COM VISITANOS !!

shakira
Mensajes: 76
Registrado: Lun Feb 14, 2011 3:15 pm

Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT

Mensajepor shakira » Vie Nov 02, 2018 6:39 pm

Buenas tardes. ¿acruz podrías facilitarme un correo para enviarte un mensaje, por favor?

Gracias.

Avatar de Usuario
Dado
Mensajes: 15824
Registrado: Mar Jul 06, 2010 8:56 pm

Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT

Mensajepor Dado » Vie Nov 02, 2018 6:42 pm

En el recuadro a la derecha del mensaje, justo abajo de su nick esta la leyenda "Contactar :" y un icono de mensaje, haz clic ahi para ver su direccion de email
Adjuntos
contactar.png
contactar.png (5.88 KiB) Visto 8501 veces
ADDENDAS? VALIDACION? CODIGO PARA PROGRAMAR TU PROPIA SOLUCION? TODO LO TENEMOS EN WWW.VALIDACFD.COM VISITANOS !!

shakira
Mensajes: 76
Registrado: Lun Feb 14, 2011 3:15 pm

Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT

Mensajepor shakira » Vie Nov 02, 2018 9:14 pm

Muchas gracias, DADO. ¿No tienes vida social? JAJAJAJA, ntc...

Que tengas un excelente fin de semana.

PD No me sale ese pequeño ícono de llamada.
Adjuntos
Sin título.png
Sin título.png (8.18 KiB) Visto 8495 veces

GoLoco
Mensajes: 3
Registrado: Vie Nov 09, 2018 12:55 pm

Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT

Mensajepor GoLoco » Vie Nov 09, 2018 1:03 pm

hola ,
Ya logre autenticarme y sacar el token, tengo y he estado analizando el codigo de halcon divino, sin embargo, estoy haciendo el request manual en Go y al momento de crear la solicitud de descarga masiva, no logro decifrar como se calcula el "DigestValue".
Nota: Si cambio fecha inicial y fecha final con programa de halcondivino sigue generando el mismo hash,eso quiere decir que no es el nodo solicitud.

Alguien tiene este dato?

Código: Seleccionar todo

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <SolicitaDescarga xmlns="http://DescargaMasivaTerceros.sat.gob.mx">
         <solicitud RfcEmisor="CHHH000421XXX" RfcSolicitante="CHHH000421XXX" FechaInicial="2018-03-01T00:00:00" FechaFinal="2018-03-07T00:00:00" TipoSolicitud="CFDI">
            <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
               <SignedInfo>
                  <CanonicalizationMethod Algorithm="Algorithm" />
                  <SignatureMethod Algorithm="Algorithm" />
                  <Reference>
                     <DigestMethod Algorithm="Algorithm" />
                     <DigestValue>onjoYp8Pcr1t0r73J3LRNGlGjIU=</DigestValue>
                  </Reference>
               </SignedInfo>
               <SignatureValue>MII...IDAQAB</SignatureValue>
               <KeyInfo>
                  <X509Data>
                     <X509IssuerSerial>
                        <X509IssuerName>OID.1.2.840.113549.1.9.2=Responsable: Administración Central de Servicios Tributarios al Contribuyente, OID.2.5.4.45=SAT970701NN3, L=Cuauhtémoc, S=Distrito Federal, C=MX, PostalCode=06300, STREET="Av. Hidalgo 77, Col. Guerrero", E=acods@sat.gob.mx, OU=Administración de Seguridad de la Información, O=Servicio de Administración Tributaria, CN=A.C. del Servicio de Administración Tributaria</X509IssuerName>
                        <X509SerialNumber>00003030310000003030343030383233000000</X509SerialNumber>
                     </X509IssuerSerial>
                     <X509Certificate>MIIGoz...eydk=</X509Certificate>
                  </X509Data>
               </KeyInfo>
            </Signature>
         </solicitud>
      </SolicitaDescarga>
   </s:Body>
</s:Envelope>

crono81
Mensajes: 118
Registrado: Lun Dic 16, 2013 6:55 pm

Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT

Mensajepor crono81 » Vie Nov 09, 2018 4:36 pm

Dale una leida al hilo completo, ahi estan las respuestas.
Debes firmar este nodo

Código: Seleccionar todo

<des:solicitud FechaFinal="2017-01-02T15:00:00" FechaInicial="2017-01-02T00:00:02" RfcEmisor="XXXXX" RfcSolicitante="XXXXX" TipoSolicitud="CFDI"></des:solicitud>';

Respetando el orden de los atributos, además ten en cuenta que yo uso el namespace "des"

GoLoco
Mensajes: 3
Registrado: Vie Nov 09, 2018 12:55 pm

Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT

Mensajepor GoLoco » Vie Nov 09, 2018 5:27 pm

hola cronos, ya lei el hilo completo tambien lei esa parte que sacando el hash de ese nodo "solicitud", pero te comento que al bajar el codigo de halcondivino, que efectua las peticiones bien, genera un mismo hash siempre aunque cambies la fechainicial y fechafinal, es decir no puede venir del nodo que dices porque que al cambiar las fechas cambia el string por consecuencia , cambia el hash.
no se si me explique bien.

Tu ya lograste hacer la peticion de descarga?

Avatar de Usuario
Dado
Mensajes: 15824
Registrado: Mar Jul 06, 2010 8:56 pm

Re: Crear SolicitaDescarga de los servicios web de descarga masiva del SAT

Mensajepor Dado » Vie Nov 09, 2018 5:35 pm

Que trabajo nos costo llegar a esa conclusion, para que te digan "NO" y ni siquiera lo intenten :roll:
ADDENDAS? VALIDACION? CODIGO PARA PROGRAMAR TU PROPIA SOLUCION? TODO LO TENEMOS EN WWW.VALIDACFD.COM VISITANOS !!


Volver a “Otros”

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 8 invitados