[DUG] Extracting Web Service data from a TRemotable
Mark Williamson at Warkworth Computer Services Limited
wcsl at kol.co.nz
Mon Apr 27 20:25:31 NZST 2009
Thanks to Trevor and Edward for responding.
I am completely lost.
The specification for this GetLatestTransactions says that it will return a
dataset.
When the code generated by the Delphi 2009 WSDL Import wizard runs, it
appears to send the request and receive a response - no error codes occur
anyway.
I have generated two transactions (timesheet lines) to be returned to me, so
presume I am getting those back.
And I am sort of expecting them to be in the record_array that I have
defined as being the result from GetLatestTransactions.
The code
unique_id := record_array.unique_id[0]
will not compile: [DCC Error] UnitMainForm.pas(58): E2157 Element 0
inaccessible - use 'Length' or 'SetLength'
unique_id := record_array.unique_id[1]
will compile, but gets an Access Violation.
unique_id := record_array[0].unique_id
will also not compile: [DCC Error] UnitMainForm.pas(58): E2149 Class does
not have a default property
unique_id := record_array.unique_id will compile, and will run, but just
returns a null result.
I think I need to find out the size of the dataset/array, and then somehow
extract the data out of it. But am at a complete loss. Which is probably
why I'm not explaining the problem very well.
Any further help will be much appreciated. I don't usually have a lot of
time pressure on sorting out problems, but in this case the organization
supplying the timesheets to my system (and lots of other systems, but not
Delphi ones) is dropping the old CSV file interface, and will only have the
Web Service.
Mark
----- Original Message -----
From: <delphi-request at delphi.org.nz>
To: <delphi at delphi.org.nz>
Sent: Monday, April 27, 2009 12:12 PM
Subject: Delphi Digest, Vol 66, Issue 47
> Send Delphi mailing list submissions to
> delphi at delphi.org.nz
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://listserver.123.net.nz/mailman/listinfo/delphi
> or, via email, send a message with subject or body 'help' to
> delphi-request at delphi.org.nz
>
> You can reach the person managing the list at
> delphi-owner at delphi.org.nz
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Delphi digest..."
>
>
> Today's Topics:
>
> 1. Re: Extracting Web Service data from a TRemotable (Trevor)
> 2. Re: Extracting Web Service data from a TRemotable
> (Edward Koryagin)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 26 Apr 2009 16:19:35 +1200
> From: "Trevor" <trevorj at ihug.co.nz>
> Subject: Re: [DUG] Extracting Web Service data from a TRemotable
> To: "'NZ Borland Developers Group - Delphi List'"
> <delphi at delphi.org.nz>
> Message-ID: <A029A02B35C9480F89B0A942FE2AA371 at zimpy>
> Content-Type: text/plain; charset="us-ascii"
>
> Mark,
>
> I'm not sure that I understand what the code is supposed to do, but I
> can't see anything (at first glance) that tells me the number of elements
> in
> the returned array.
>
>
>
> unique_id := record_array.UniqueId[1]; would normally refer to the second
> element in the array. Are there 2?
>
>
>
> If not, that could be the cause of the AV.
>
>
>
> Trevor
>
>
>
>
>
> _____
>
> From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
> On
> Behalf Of Mark Williamson at Warkworth Computer Services Limited
> Sent: Saturday, 25 April 2009 11:19 a.m.
> To: delphi at delphi.org.nz
> Subject: [DUG] Extracting Web Service data from a TRemotable
>
>
>
> 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/20090426/5a3cdd68/attachment-0001.html
>
> ------------------------------
>
> Message: 2
> Date: Sat, 25 Apr 2009 23:13:29 -0700 (PDT)
> From: Edward Koryagin <ed_iv2001 at yahoo.co.nz>
> Subject: Re: [DUG] Extracting Web Service data from a TRemotable
> To: NZ Borland Developers Group - Delphi List <delphi at delphi.org.nz>
> Message-ID: <382769.55857.qm at web65611.mail.ac4.yahoo.com>
> Content-Type: text/plain; charset=utf-8
>
>
> record_array[0].UniqueId;
>
> Edward Koryagin
>
>
> --- On Sat, 25/4/09, Mark Williamson at Warkworth Computer Services
> Limited <wcsl at kol.co.nz> wrote:
>
>> From: Mark Williamson at Warkworth Computer Services Limited
>> <wcsl at kol.co.nz>
>> Subject: [DUG] Extracting Web Service data from a TRemotable
>> To: delphi at delphi.org.nz
>> Received: Saturday, 25 April, 2009, 11:19 AM
>> 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
>> _______________________________________________
>> NZ Borland Developers Group - Delphi mailing list
>> Post: delphi at delphi.org.nz
>> Admin: http://delphi.org.nz/mailman/listinfo/delphi
>> Unsubscribe: send an email to delphi-request at delphi.org.nz
>> with Subject: unsubscribe
>
>
> Get the world's best email - http://nz.mail.yahoo.com/
>
>
>
> ------------------------------
>
> _______________________________________________
> Delphi mailing list
> Delphi at delphi.org.nz
> http://listserver.123.net.nz/mailman/listinfo/delphi
>
> End of Delphi Digest, Vol 66, Issue 47
> **************************************
More information about the Delphi
mailing list