Search code examples
arrayssoapwsdldelphi-xe8

WSDL with Delphi XE8 array initialize


I have this WSDL imported with Delphi XE8, I can not initialize array.

type
elencoDettagliPrescrInviiErogatoType = array of 
dettaglioPrescrizioneInvioErogatoType;
----------------------------------
dettaglioPrescrizioneInvioErogatoType = class(TRemotable)
private
FcodProdPrest: stringType;
----------------------------------

InvioErogatoRichiesta = class(TRemotable)
….
Published
property ElencoDettagliPrescrInviiErogato: elencoDettagliPrescrInviiErogatoType  read FElencoDettagliPrescrInviiErogato write FElencoDettagliPrescrInviiErogato;
--------------------------------


function  invioErogato(const InvioErogatoRichiesta: InvioErogatoRichiesta): 
InvioErogatoRicevuta; stdcall

My call

procedure Tform1.Button1Click(Sender: TObject);
var
richiestaInvio : InvioErogatoRichiesta;
ricevutaInvio  : InvioErogatoRicevuta;
begin
richiestaInvio :=  InvioErogatoRichiesta.Create;
// how to initialize arrays?
setlength(richiestaInvio.ElencoDettagliPrescrInviiErogato,1);
// Error memory not read 
richiestaInvio.ElencoDettagliPrescrInviiErogato[0].codProdPrest := 'Codice_test';
...
end;

I tried various ways to inizzialize ElencoDettagliPrescrInviiErogato[0] Without success.


Solution

  • The solution is: declare a variable var richiestaInvio : InvioErogatoRichiesta; ricevutaInvio : InvioErogatoRicevuta; dettagliImp : elencoDettagliPrescrInviiErogatoType; // initializes array begin richiestaInvio := InvioErogatoRichiesta.Create; ricevutaInvio := InvioErogatoRicevuta.Create; //my problem was this. Now solved! setlength(dettagliImp,1); // create dipendence dettagliImp[0] := dettaglioPrescrizioneInvioErogatoType.create(); //popolate field array dettagliImp[0].codProdPrest :='cod test'; //ecc. // end richiestaInvio.ElencoDettagliPrescrInviiErogato := dettagliImp; ...