Access Violation variable type Txsdate

Asked

Viewed 56 times

0

I am doing the integration with the webservice of Total Express Transport and importing the wsdl made available by them has been created several properties where types are Txsdecimal and Txsdate.

When trying to assign a value to a property that has the type as Txsdate this occurs the access error Violation.

Below follows the code I am developing:

procedure TForm1.Button3Click(Sender: TObject);
var
  Registra : RegistraColetaRequest;
  AuxEncomendas : Encomendas;
  AuxNfe : DocFiscalNFe;   
  encom : Encomenda;
  nota : NFe;    
begin    
  Registra := RegistraColetaRequest.Create;
  TXSDate.Create;

  encom := Encomenda.Create;
  encom.IdCliente := 'teste';
  encom.DestNome := 'Destinatario teste';

  SetLength(AuxEncomendas, 1);
  Registra.CodRemessa := '1315';  

  nota := NFe.Create;
  nota.NfeChave := '12315645645645564';

  //Nesta linha ocorre o erro comentado
  nota.NfeData.AsDate := Date;

  SetLength(AuxNfe, 1);
  AuxNfe[0] := nota;

  encom.DocFiscalNFe := AuxNfe;

  AuxEncomendas[0] := encom;
  Registra.Encomendas := AuxEncomendas;

 (HTTPRIO as webservice_v24_totalPortType).RegistraColeta(Registra);    
end; 

1 answer

0


If it is a TXSDateTime you cannot assign directly. Something like...

uses
  Soap.XSBuiltIns;
...

var
  vDataTxs: TXSDateTime;
begin
  vDataTxs := TXSDateTime.Create;
  vDataTxs.XSToNative(FormatDateTime('yyyy-mm-dd', Data_Desejada) + 'T00:00:00.000-03:00');
...
end;

Now to recover this date back (you received it via xml) beware of using the .AsUTCDateTime.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.