Конференция "Начинающим" » динамический массив со сложным именем
 
  • petrovs4shencka © (25.02.18 09:37) [0]
    Подсажите как создать динамический массив со сложным именем и вообще что не так делаю? В код надо вставить что-то типа этого  SetLength(api.patinf.inrancs.list,1)
    Пример запроса: Добавление данных метод: addPat

    <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:xmethods-delayed-quotes" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
      <soapenv:Header/>
      <soapenv:Body>
         <urn:addPat soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <PatInf xsi:type="ris:AddPatInf" xmlns:ris="http://ris.kem.service">
               <code xsi:type="xsd:string">669


               <tnk xsi:type="xsd:string">6dcee</tnk>
               <patinf xsi:type="ris:patInf">
                  <lnm xsi:type="xsd:string">0002422</lnm>
                  <fnm xsi:type="xsd:string">00004</fnm>
                  <inrancs xsi:type="ris:pat_inrancs_w">
                     <list xsi:type="ris:pat_inrancs" soapenc:arrayType="ris:inranc[]">
                      <inranc>
                       <locode>205</locode>
                           <lic>0000001</lic>
                       <begindate>2001-01-01</begindate>
                      </inranc>
                     </list>
                  </inrancs>
             </patinf>
            </PatInf>
         </urn:addPat>
      </soapenv:Body>
    </soapenv:Envelope>

    Пример ответа об успешной передаче:

    <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Body>
         <ns1:addPatResponse>
            <Result xsi:type="xsd:int">9</Result>
         </ns1:addPatResponse>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>


    Код delphi:

    unit Unit1;

    interface

    uses
     Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
     Vcl.Controls, Vcl.Forms, Vcl.Dialogs, kem, Soap.InvokeRegistry, Vcl.StdCtrls, Soap.Rio, Soap.SOAPHTTPClient;

    type
     TForm1 = class(TForm)
       HTTPRIO1: THTTPRIO;
       Button1: TButton;
       Edit1: TEdit;
       procedure Button1Click(Sender: TObject);
     private
       { Private declarations }
     public
       { Public declarations }
     end;

    var
     Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.Button1Click(Sender: TObject);
    var
    api:AddPatInf;
    KPa:Integer;
    begin
    Application.ProcessMessages;
    HTTPRIO1.HTTPWebNode.ConnectTimeout := 1000 * 60 * 1;
    HTTPRIO1.HTTPWebNode.ReceiveTimeout := 1000 * 60 * 5;
    api:=AddPatInf.Create;
    api.code:='669';
    api.tnk:='6dcee';
    api.patinf:=patinf.Create;
    api.patinf.lnm:='0002422';
    api.patinf.fnm:='00004';

    api.patinf.inrancs:=pat_inrancs_w.Create;
    api.patinf.inrancs.list:=pat_inrancs.Create();
    api.patinf.inrancs.list[0]:=inranc.Create;//ошибка присвоения
    api.patinf.inrancs.list[0].locode:=205;
    api.patinf.inrancs.list[0].lic:='0000001';
    api.patinf.inrancs.list[0].begindate:=TXSDate.Create;
    api.patinf.inrancs.list[0].begindate.AsDate:=StrToDate('01.01.2001');

    KPa:=(HTTPRIO1 as rpnPortType).addPat(api);//function addPat(const PatInf: AddPatInf): Integer; stdcall;
    Edit1.Text:=IntToStr(KPa);

    api.patinf.inrancs.list[0].begindate.Free;
    end;

    end.

  • kilkennycat © (25.02.18 17:01) [1]

    > AddPatInf

    это что?

    > AddPatInf.Create;

    это что?

    > patinf.Create;

    это что ?

    > pat_inrancs_w.Create;

    это что?

    > inranc.Create;

    это что?

    > TXSDate.Create;

    это что?

    > api.patinf.inrancs.list[0].begindate.Free;

    это что?
  • petrovs4shencka © (25.02.18 22:19) [2]

    type
    AddPatInf       = class;
    inranc          = class;
    pat_inrancs_w   = class;
    patInf          = class;
    pat_inrancs = array of inranc;

     // ************************************************************************ //
     // XML       : AddPatInf, global, <complexType>
     // Namespace : http://ris.kem.service
     // ************************************************************************ //
     AddPatInf = class(TRemotable)
     private
       Fcode: string;
       Ftnk: string;
       Fpatinf: patinf;
     public
       destructor Destroy; override;
     published
       property code:      string       read Fcode write Fcode;
       property tnk:       string       read Ftnk write Ftnk;
       property patinf: patinf  read Fpatinf write Fpatinf;
     end;
     

     // ************************************************************************ //
     // XML       : inranc, global, <complexType>
     // Namespace : http://ris.kem.service
     // ************************************************************************ //
     inranc = class(TRemotable)
     private
       Flocode: string;
       Fsmo_localcode_Specified: boolean;
       Flic: string;
       Fbegindate: TXSDate;
       procedure Setlocode(Index: Integer; const Astring: string);
       function  locode_Specified(Index: Integer): boolean;
       procedure Setlic(Index: Integer; const Astring: string);
       function  lic_Specified(Index: Integer): boolean;
     public
       destructor Destroy; override;
     published
       property locode:     string   Index (IS_OPTN) read Flocode write Setlocode stored locode_Specified;
       property lic:        string   Index (IS_OPTN) read Flic write Setlic stored lic_Specified;
       property begindate:  TXSDate  read Fbegindate write Fbegindate;
     end;

     // ************************************************************************ //
     // XML       : pat_inrancs_w, global, <complexType>
     // Namespace : http://ris.kem.service
     // ************************************************************************ //
     pat_inrancs_w = class(TRemotable)
     private
       Fforcewrite: Integer;
       Fforcewrite_Specified: boolean;
       Flist: pat_inrancs;
       procedure Setforcewrite(Index: Integer; const AInteger: Integer);
       function  forcewrite_Specified(Index: Integer): boolean;
     public
       destructor Destroy; override;
     published
       property forcewrite: Integer      Index (IS_OPTN) read Fforcewrite write Setforcewrite stored forcewrite_Specified;
       property list:       pat_inrancs  read Flist write Flist;
     end;

     // ************************************************************************ //
     // XML       : patInf, global, <complexType>
     // Namespace : http://ris.kem.service
     // ************************************************************************ //
     patInf = class(TRemotable)
     private
       Flnm: string;
       Ffnm: string;
       Finrancs: pat_inrancs_w;
       Finrancs_Specified: boolean;
       procedure Setinrancs(Index: Integer; const Apat_inrancs_w: pat_inrancs_w);
       function  inrancs_Specified(Index: Integer): boolean;
     public
       destructor Destroy; override;
     published
       property lnm:       string                    read Flnm write Flnm;
       property fnm:       string                    read Ffnm write Ffnm;
       property inrancs:   pat_inrancs_w      Index (IS_OPTN) read Finrancs write Setinrancs stored inrancs_Specified;
     end;
  • petrovs4shencka © (25.03.18 00:48) [3]
    Спасибо всем!
    Получилось вот так:

    var
    arr:pat_inrancs;
    lst:inranc;
    ...
    SetLength(arr,1);
    api.patinf.inrancs.list:=arr;
    api.patinf.inrancs.list[0]:=lst;

 
Конференция "Начинающим" » динамический массив со сложным именем
Есть новые Нет новых   [118453   +48][b:0][p:0.004]