Delphi SOAP数组问题

Delphi SOAP数组问题,第1张

概述我有一个用delphi创建的SOAP应用程序. 输入到服务器正确.但输出总是空的. r对象(响应)创建,但长度(r.notes)总是0.如果我没有数组的应用程序,它也正常工作.哪里有问题?谷歌搜索和尝试不同组合3天没有帮助. 接口: ////////////// INPUT ///////////////////////type TClientInformationStructure= clas 我有一个用delphi创建的SOAP应用程序.

输入到服务器正确.但输出总是空的. r对象(响应)创建,但长度(r.notes)总是0.如果我没有数组的应用程序,它也正常工作.哪里有问题?谷歌搜索和尝试不同组合3天没有帮助.

接口:

////////////// input ///////////////////////type TClIEntinformationStructure= class(TRemotable)  private    fClIEntApplicationname:string;    fClIEntApplicationPassword:string;    fRequestIDentifIEr:string;    fStartSequenceNumber:integer;    fNumberOfNotes:integer;  published    property ClIEntApplicationname:string read fClIEntApplicationname  write fClIEntApplicationname;   //name of calling application    property ClIEntApplicationPassword:string read fClIEntApplicationPassword write fClIEntApplicationPassword;          //Password that calling application must use to call the service    property RequestIDentifIEr:string read fRequestIDentifIEr write fRequestIDentifIEr;//TransaktionsID from calling system that is stamped in all loggings for service,//so that later it is easy to compare clIEnt and server logs. May be null.    property StartSequenceNumber:integer read fStartSequenceNumber write fStartSequenceNumber;    property NumberOfNotes:integer read fNumberOfNotes write fNumberOfNotes;end;///////////// OUTPUT ////////////////////////////Type TNote=class(tremotable)  private    fNotetID:string;    fSequenceNumber:integer;    fDeleteMark:boolean;    fAuthorRole:string;    fAuthorUsername:string;    fAuthor:string;    fAcceptTime:tdateTime;    fOrganizationalUnit:string;    fLocationStartTime:tdateTime;    fLocationEndTime:TdateTime;    fBeaDWard:string;    fPersonCivilRegistrationIDentifIEr:string;    fNoteType:string;    fNoteText:string;    fMoreNotesAvailable:boolean;  public    property NotetID:string read fNotetID  write fNotetID;    property SequenceNumber:integer read fSequenceNumber write fSequenceNumber;    property DeleteMark:boolean read fDeleteMark write fDeleteMark;    property AuthorRole:string read fAuthorRole write fAuthorRole;    property AuthorUsername:string read fAuthorUsername write fAuthorUsername;    property Author:string read fAuthor write fAuthor;    property AcceptTime:tdateTime read fAcceptTime write fAcceptTime;    property OrganizationalUnit:string read fOrganizationalUnit write fOrganizationalUnit;    property LocationStartTime:tdateTime read fLocationStartTime write fLocationStartTime;    property LocationEndTime:TdateTime read fLocationEndTime write fLocationEndTime;    property BeaDWard:string read fBeaDWard write fBeaDWard;    property PersonCivilRegistrationIDentifIEr:string read fPersonCivilRegistrationIDentifIEr write fPersonCivilRegistrationIDentifIEr;    property NoteType:string read fNoteType write fNoteType;    property NoteText:string read fNoteText write fNoteText;    property MoreNotesAvailable:boolean read fMoreNotesAvailable write fMoreNotesAvailable;end;type TnoteStructure = array of TNote;type tNoteCollection=class(tremotable)  private    fnotes:TnoteStructure;  public    property notes:TnoteStructure read fnotes write fnotes;end;type  ibla = interface(IInvokable)   ['{FFD831EC-56B1-4C0E-9CCE-8D9C7ECEE656}']    function GetNotes(ClIEntinformationStructure:TClIEntinformationStructure)              : tNoteCollection; stdcall;  end;implementationinitialization  RemClassRegistry.RegisterXSClass(TClIEntinformationStructure);  RemClassRegistry.RegisterXSClass(Tnote);  RemClassRegistry.RegisterXSClass(tNoteCollection);  RemClassRegistry.RegisterXSInfo(TypeInfo(TnoteStructure));  InvRegistry.RegisterInterface(TypeInfo(ibla));finalization  RemClassRegistry.UnRegisterXSClass(TClIEntinformationStructure);  RemClassRegistry.unRegisterXSClass(Tnote);  RemClassRegistry.unRegisterXSClass(tNoteCollection);  RemClassRegistry.unRegisterXSInfo(TypeInfo(TnoteStructure));  InvRegistry.UnRegisterInterface(TypeInfo(ibla));end.

执行:

type  Tbla = class(TInvokableClass,ibla)  public    function GetNotes(ClIEntinformationStructure:TClIEntinformationStructure)              : TNotecollection; stdcall;  end;implementationfunction Tbla.GetNotes(ClIEntinformationStructure:TClIEntinformationStructure)              : TNotecollection;var n:tNoteStructure;begin  try    result:=TNotecollection.Create;    setlength(n,1);    n[0]:=tnote.create;    n[0].NotetID:=inttostr(random(100));    n[0].AuthorUsername:='!1!'+ClIEntinformationStructure.ClIEntApplicationname;    n[0].SequenceNumber:=999;    result.notes:=copy(n);  except    on e:exception do addtolog(e.Message)  end;end;initialization  InvRegistry.RegisterInvokableClass(Tbla)finalization  InvRegistry.unRegisterInvokableClass(Tbla)

客户端:

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:=(httpRIO1 as ibla).GetNotes(c);    if assigned(r) then      if length(r.notes)>0 then        if assigned(r.notes[0]) then showmessage(r.notes[0].AuthorUsername);  finally    freeandnil(c);    if assigned (r.notes[0]) then freeandnil(r.notes[0]);    if assigned(r) then freeandnil(r);  end;
解决方法 在服务器中,要转到SOAP Web模块,请选择httpSoapPascalinvoker组件,然后在Object Inspector中打开Options属性.确保选中“soRootRefNodesToBody”选项.这将确保在SOAP共振中,元素被传递到响应节点之外,在主体中,客户端可以在其中找到它们.

Groetjes,Bob Swart

总结

以上是内存溢出为你收集整理的Delphi SOAP数组问题全部内容,希望文章能够帮你解决Delphi SOAP数组问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1279318.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存