带有Delphi XE8数组的WSDL初始化

时间:2019-02-23 11:29:03

标签: arrays soap wsdl delphi-xe8

我已将此Delphi XE8导入的WSDL,无法初始化数组。

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

我的电话

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;

我尝试了各种方法来使ElencoDettagliPrescrInviiErogato [0]泛滥,但没有成功。

1 个答案:

答案 0 :(得分:0)

解决方案是:声明一个变量      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; ...