[DUG] Extracting Web Service data from a TRemotable
Mark Williamson at Warkworth Computer Services Limited
wcsl at kol.co.nz
Sat Apr 25 11:19:14 NZST 2009
Hi,
This is my first question to the Digest, so I hope this is right way of submitting it.
I am trying to consume a Web Service. Have got it working ok for simple returns of XML strings, but am completely stuck on how to handle the return of multiple records in a TRemotable Object.
Here's the code that I think relates to it:
GetLatestTransactionsResult = class(TRemotable)
private
FUniqueId:String;
FPeopleId:String;
FSiteLoginId:string;
FSiteLogoutId:string;
FErrorCode:integer;
published
Property UniqueId: string read FUniqueId write FUniqueId;
Property PeopleId: string read FPeopleId write FPeopleId;
Property SiteLoginId: string read FSiteLoginId write FSiteLoginId;
Property SiteLogoutId: string read FSiteLogoutId write FSiteLogoutId;
Property ErrorCode: integer read FErrorCode write FErrorCode;
end;
TFieldInfoArray = array of GetLatestTransactionsResult;
DataPortalExSoap = interface(IInvokable)
['{94DBE733-A57C-9EBF-B5CD-167163F4ECAF}']
function GetLatestTransactionsEx(const ID: string; const Password: string; const ExternalRef: string; const FindByBatchNo: string; const FindByExternalRef: string): string; stdcall;
end;
initialization
RemClassRegistry.RegisterXSClass(GetLatestTransactionsResult, 'http://www.ezitracker.com/eziTrackerData/', 'GetLatestTransactionsResult');
RemClassRegistry.RegisterXSClass(GetLatestTransactionsResult, '', 'TFieldInfo', '');
RemTypeRegistry.RegisterXSInfo(TypeInfo(TFieldInfoArray), '', 'TFieldInfoArray');
finalization
RemClassRegistry.UnRegisterXSClass(GetLatestTransactionsResult);
RemTypeRegistry.UnRegisterXSInfo(TypeInfo(TFieldInfoArray));
and then on the Form with my test buttons:
procedure TFormMainForm.ButtonGetLatestTransactionsClick(Sender: TObject);
var id:string;
password:string;
nonnullresponse:boolean;
record_array:GetLatestTransactionsResult;
unique_id:string;
begin
id := 'aaa';
password := 'bbb';
nonnullresponse := True;
record_array := GetDataPortalExSoap.GetLatestTransactions(id, password, nonnullresponse);
end;
It appears to run ok, but I have no idea how to extract the data from record_array.
If I try something as simple as:
unique_id := record_array.UniqueId[1];
I get an EAccessViolation.
Can anyone help please.
I can't seem to find any ideas on the Web, probably because the answer it too obvious.
Thanks
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20090425/3aa6a465/attachment.html
More information about the Delphi
mailing list