Delphi SOAP arrays problem

后端 未结 3 969
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 07:19

I have a SOAP application created with delphi.

Input comes to server correct. But output is always empty. r object (response) created, but length

3条回答
  •  生来不讨喜
    2021-01-05 08:08

    Thanks to all. All works fine with this code:

    Server

    Interface part:

    interface
    
    const
      IS_OPTN = $0001;
      IS_UNBD = $0002;
    
    type tNoteCollection=class(tremotable)
      private
        fnotes:TnoteStructure;
        procedure Setnotes(Index: Integer; const anotes: TnoteStructure);
      published
        property notes:TnoteStructure index(IS_OPTN or IS_UNBD)  read fnotes write setnotes;
        procedure setlen(count:byte);
        function getlen:integer;
    end;
    
    implementation
    
    procedure tNoteCollection.setlen(count:byte);
    begin
       setlength(fnotes,count);
    end;
    
    function tNoteCollection.getlen:integer;
    begin
       result:=length(fnotes);
    end;
    
    procedure tNoteCollection.Setnotes(Index: Integer; const anotes: TnoteStructure);
    begin
      fnotes:=anotes;
    end;
    

    Implementation part:

    function Tcis2opus.GetNotes(ClientInformationStructure:TClientInformationStructure)
                  : tNoteCollection;
    begin
      try
        result:=tNoteCollection.Create;
        result.setlen(1);
        result.notes[0]:=tnote.create;
        result.notes[0].NotetId:=inttostr(random(100));
        result.notes[0].AuthorUserName:='!1!'+ClientInformationStructure.ClientApplicationName;
        result.notes[0].SequenceNumber:=999;
      except
        on e:exception do addtolog(e.Message)
      end;
    end;
    

    Client

    procedure TForm1.BitBtn1Click(Sender: TObject);
    var c:tclientinformationstructure;
        r:tNoteCollection;
    begin
      c:=tclientinformationstructure.Create;
      try
        c.ClientApplicationName:=labelededit1.Text;
        c.ClientApplicationPassword:=labelededit2.Text;
        c.RequestIdentifier:=labelededit3.Text;
        c.StartSequenceNumber:=strtointdef(labelededit4.Text,0);
        c.NumberOfNotes:=strtointdef(labelededit5.Text,0);
        r:=nil;
        r:=(HTTPRIO1 as iCIS2Opus).GetNotes(c);
          if r.getlen>0 then
            if assigned(r.notes[0]) then showmessage(r.notes[0].AuthorUserName);
      finally
        if assigned(c) then freeandnil(c);
        if assigned(r) then freeandnil(r);
      end;
    end;
    

提交回复
热议问题