How to return a record?

Hello,

still playing with the DataSnap REST basics.
I just created a new method which should return a custom type which is a
record containing say a string and an integer for the start.

If I try to call this from the browser I get a JSON formatted error
message telling me that the method has not been found in the server's
method list.

If I change it to just return a string or just return an integer it
works as expected.

Now how to return a record with some fields?
Amnother thing I got stuck with: the course ware book I use to learn
more contains a list of supported datatypes for JSON return values. For
dates this is the TDBXdate type. But where would I find a conversion
routine from say TDate to this format?

I know it is used in datasets and for DB access, but if I'd have to
return something like the value of now, how to do this?

Greetings

Markus
0
Markus
5/28/2015 6:29:23 PM
embarcadero.delphi.webservices 976 articles. 0 followers. Follow

5 Replies
830 Views

Similar Articles

[PageSpeed] 28

Am 28.05.2015 um 20:29 schrieb Markus Humm:
> Hello,
> 
> still playing with the DataSnap REST basics.
> I just created a new method which should return a custom type which is a
> record containing say a string and an integer for the start.
> 
> If I try to call this from the browser I get a JSON formatted error
> message telling me that the method has not been found in the server's
> method list.
> 
> If I change it to just return a string or just return an integer it
> works as expected.
> 
> Now how to return a record with some fields?
> Amnother thing I got stuck with: the course ware book I use to learn
> more contains a list of supported datatypes for JSON return values. For
> dates this is the TDBXdate type. But where would I find a conversion
> routine from say TDate to this format?
> 
> I know it is used in datasets and for DB access, but if I'd have to
> return something like the value of now, how to do this?
> 
> Greetings
> 
> Markus
> 

Hello,

I found a solution now via System.JSON and
GetIOnvocationMetaData.ResponseContent.

I can define a TObject descendant then and have this easily converted
into JSON. But: why does it convert the private fields as well? Is there
any official solution besides calling RemovePair for all such fields?
that would be cumbersome.

Greetings

Markus
0
Markus
5/28/2015 8:58:57 PM
Hi Markus,

Not sure if this will help you.

http://www.embarcadero.com/rad-in-action/delphi-labs

Did you see this already? 
On episode 10 you find passing object 
properties by DataSnap.
(Note the link to the whitepaper..)

For passing records I think you should choose one of the
internet data methods like JSON or XML string. These
structures can pass lists of records (or a single record)
It shouldn't be hard to create a method that formats any
Delphi data structure into a XML or JSON sting and return
it by DataSnap.
0
Robert
5/30/2015 6:55:54 PM
Am 30.05.2015 um 20:55 schrieb Robert Triest:
> Hi Markus,
> 
> Not sure if this will help you.
> 
> http://www.embarcadero.com/rad-in-action/delphi-labs
> 
> Did you see this already? 
> On episode 10 you find passing object 
> properties by DataSnap.
> (Note the link to the whitepaper..)
> 
> For passing records I think you should choose one of the
> internet data methods like JSON or XML string. These
> structures can pass lists of records (or a single record)
> It shouldn't be hard to create a method that formats any
> Delphi data structure into a XML or JSON sting and return
> it by DataSnap.
> 

Hello,

thanks for your help. As for objects I found that out already and that's
really easy. I even found ozut now, that you can limit what is being
sent by using the $RTTI directive. Otherwise all the private fields
would get send as well. Yuck! ;-)

Greetings

Markus
0
Markus
5/31/2015 7:06:13 AM
> thanks for your help. As for objects I found that out already and that's
> really easy. I even found ozut now, that you can limit what is being
> sent by using the $RTTI directive. Otherwise all the private fields
> would get send as well. Yuck! ;-)

Ah, thats new for me. To pass an object, did you use the same method
as in Pavel's DataSnap episode 10?

Are you planning a whitepaper as well ? ;-))
0
Robert
6/1/2015 9:07:36 AM
Am 01.06.2015 um 11:07 schrieb Robert Triest:
>> thanks for your help. As for objects I found that out already and that's
>> really easy. I even found ozut now, that you can limit what is being
>> sent by using the $RTTI directive. Otherwise all the private fields
>> would get send as well. Yuck! ;-)
> 
> Ah, thats new for me. To pass an object, did you use the same method
> as in Pavel's DataSnap episode 10?
> 
> Are you planning a whitepaper as well ? ;-))
> 

Hello,

I don't pass an object, I simply return it:

{code}
type
  TMyClass = class(TObject)
    Field1: Integer;
  end;

[..]

and in the server datamodule:

private
  FMyClass: TMyCLass;
public
  function GetMyClass: TMyClass;

[..]

function TXXX.GetMyClass: TMyClass;
begin
  result := FMyClass;
end;
{code}

Where's the problem? ;-)

Greetings

Markus
0
Markus
6/1/2015 6:18:54 PM
Reply:

Similar Artilces:

D2010 Passing user defined records as parameters to Delphi DLL and returning records
Hi Friends: I have a simple question... I have a *Huge* account system, made in Delphi 2010. It works ok. I have external MODULES made in Delphi 2010. They are DLL. So, i need to share information between them, using records like those (example) TAnotherRecord = record field1, field3 : widestring; ComplexField: TRecordComplex; end; TPlusRecord = record field1, fieldA, fieldB: widestring; end; TMyRecord = record someField: TAnotherRecord; otherField: TPlusRecord; end; All these type are shared in definitions in main EXE and DLLs FIRST PROBLEM...

Delphi
Hi, I have a webservice from SAP, it has one operation "ZMymcsCustomersMulti" <wsdl:operation name="ZMymcsCustomersMulti"> <wsp:Policy> <wsp:PolicyReference URI="#OP_ZMymcsCustomersMulti"/> </wsp:Policy> <wsdl:input message="tns:ZMymcsCustomersMulti"/> <wsdl:output message="tns:ZMymcsCustomersMultiResponse"/> </wsdl:operation> As you can see the return value should be of the type "ZMymcsCustomersMultiResponse". After I imported this service into my delphi p...

WebService won't return all records
Aloha, I used a webservice to return some data in my  DB, and the return type is datatable, which is new in .Net 2.0. But the problem is I have 200 records in DB, but WebService won't return all of them, maybe only 15 in all. Could any one tell me what's wrong?  Thank you. Bump! Anyone knows? can u copy the code here? Hi, It would be strange if you can return a DataTable from WebService. The DataTable, DataRow, DataView, and DataViewManager objects cannot be serialized and cannot be returned from an XML Web service. To return less than a complete DataSet, you mu...

Conditional WHERE Clause To Return One Record Or All Records
Hi,  I am attempting to create a conditional WHERE clause within an AccessDataSource object.  With SQL Server, I would normally use something like the following for the WHERE clause: WHERE @Id IS NULL OR( @Id IS NOT NULL AND TableName.Id = @Id) This would normally function perfectly to return, either one record with a matching Id to the @Id parameter value, or all of the records.  However, with the AccessDataSource object, this does not seem to work.  It only works to return the single record with the matching Id, and fails to return all records when the @Id ...

Bugzilla database does not return some records in the order in which they were recorded
Hi, I'm seeing a peculiar issue in my Bugzilla installation (Bugzilla 2.20/MySQL 4.1). When I query a bugzilla record, I find that some records are not delivered in the order in which they were recorded. To illustrate, my Bugzilla database has 2,275 records. When I'm browsing the records one-by-one, I find that the records are listed as shown below: 167 189 <- 168 .... 188 190 <- .... 330 331 337 <- 332 .... Thus, records 189, 190 and 337 are out of place. Because of this problem, my Perforce Jobs are not mapped one-to-one with Bugzilla IDs. The Per...

To suppress record number when no record is returned by selection formula
hi friends, its me again. well iam using a selection formula ..when no records is returned ..the record number iam using is displayin 1 in its field in the report.. help me how to suppress this record number when no records is returned using selection formula ...by the way help me to find the records number returned by a selection formula...COUNTING ON YOUR EXPERTNESS..Help me.. iam very desperate.. bye arul ...

Secure the data in XML (returned by a webservice) during Webservice calls
          My website has a flash object which call a webserviec which returns a xml back to flash.  How can i secure the data which is passed through the XML.  That is I dont want any users read the xml which i am giving to falsh object using any tools like fiddler, fire bug etc... Please give me your valuable suggestions and IdeasRegards    Hi, check this URL regarding secured web service   http://msdn2.microsoft.com/en-us/library/aa302428.aspx...

Returning parents and all child records, while filtering on the child record
Sorry about the confusing title.Here's what I want to do:Get a list of all Parents, and ALL their children, which have a child meeting the specified criteria.i.e.SELECT * FROM Parents INNER JOIN Children ON ....WHERE Children.Field = @Valuewill NOT return the result set I want because I want ALL children meeting the criteria. Put in real-life terms, I would like (for example), a list of all addresses, with a FULL list of residents in each address, where any of the residents is called 'Bob'.I could do something like:SELECT * FROM Parents INNER JOIN Children ON ....WHERE Paren...

how to retrieve a value which is returned by a webservice method by using the webservice behavior
Hello Mate,                     I am using the webservice behavior to call a webservice method through internet. but i have a problem in getting a value which is returned from a webservice method. the jscript shown below is not working. Could u please help me in this ? This is my web method:<WebMethod(True)> _ Public Function add(ByVal a As Integer, ByVal b As Integer)Return a + b End Function  This is my jscript file: Function add() {  service.useService("GridTasks.a...

Does a ScriptService enabled WebService return JSON? If so how do you return database information?
I have read that when you use the [ScriptService] attribute in a WebService the webservice returns JSON.  Is that accurate?  If so what do you do when you want to return database queries from your web service?  I have mostly seen simple examples that add two numbers and return an int or simple hello world string. Just wondering how to proceed. Thank you. Hi,the default's indeed JSON but you could alter it by using the ScriptMethod attribute and in that set the ResponseFormat = Xml.Grz, Kris. Read my blog. Handy Firefox plugins for web developers.Workaround for non work...

No result return from webservice in one server. Other server can return.
I had an application that consume a webservice and this application is deployed to 2 server (Server A & B). Server A return empty result. Before that it work ok with resultServer B return result. No error or exception for Server A.What will be the problem for Server A not returning any result?Server A is window server 2000Server B is window server 2003Thanks. Hi jingzo, From your description, I want you to clarify these questions. First, is the web service in a third server? As you said, we can know the application is deployed in both Server A and Server B...

Webservice returns a valid SOAP response but proxy returns null
Hi, We've been having real trouble consuming a webservice on an Apache server in C#, I've scoured the various forum posts discussing a dodgy namespace, casing and updating the OperationContractAttribute attribute but none of them seem to fit (unless I'm missing something). From what I can see, it all looks fine so I was wondering if anyone else could shed any light on what we're missing. The platform is C# .Net 3.5, I'm working in Visual Studio 2008 SP1 and have been inspecting the response using Fiddler 2. I've uploaded the WSDL (with the end point r...

Select .. Group By returns tables records not result set records
Having a problem with "GROUP BY" in DBexpress and Interbase (firebird engine) where it is not returning the # of records in the result set but of the number or records in the table. What am I doing wrong? Using this query Select group_id from table group by group_id in DBX Firebird/Interbase/Mysql returns the correct result set, but the record count is the # of records in the table On the other hand using TIBQuery with the same query returns the grouped dataset, but sets the recordcount to 1, you can use .next to get the next record til the result set is reached. i...

Return from a webservice
 I have a javascript function that makes a call to a web service.  The data is going through to the web service correctly, however, The web service uses a Try... Catch block to update a database.  If it works, it's supposed to return true, and if it doesn't the web service returns false.  Putting breakpoints in the .asmx I can see that the Update is working, and the web service is trying to return True but this never gets back to the Javascript. if (ItemUpdate.UpdateItemStatus(ItemID, "MarkedForReturned")){// do some stuff}  The web service is ...

Web resources about - How to return a record? - embarcadero.delphi.webservices

Récord - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

The Record
Great new podcast co-hosted by Chris Parrish and Brent Simmons: The Record brings you the stories you should know about the Mac and Cocoa development ...

Lompoc Record - Lompoc, California News
The first time Jerry Brown was governor of California, he earned the nickname “Gov. Moonbeam.” It was, after all, the tail-end of the Hippie ...

Bose Brings On Grey as First Global Creative Agency of Record
Headphone and speaker maker Bose has appointed Grey as its first global creative agency following a competitive review, according to people familiar ...

Record important conversations with iReg for Apple Watch
You may use your iPhone to record conversations so that you can listen to them later. But, for something even more convenient, you can now do ...

Bernie Sanders Scores Big Win; Breaks Major Fundraising Record
... the poll yourself to see the most current result). From the Sanders campaign : Bernie Sanders Scores Big Win; Breaks Major Fundraising Record ...

Here's all the dramatic video from last night's record-setting landing by SpaceX
SpaceX has set a record in the race to make commercial space flight a reality. Elon Musk and his company have successfully launched and landed ...

Unseasonable heat melts records across the country - Videos - CBS News
Temperatures across the country are out of whack. They’ll be in the 50s and 60s from the Midwest to the Northeast Tuesday, and it’s going to ...

Limbaugh On Clinton’s LONG Bathroom Break: ‘Where Are Her Medical Records?’
Limbaugh On Clinton’s LONG Bathroom Break: ‘Where Are Her Medical Records?

Midday open thread: Latest 'Star Wars' hits box office record; climate change eats Canadian island
... not realize his mistake until after Ms. Gutiérrez had begun to soak up the glory of the title. • Star Wars: The Force Awakens brings in record ...

Resources last updated: 12/23/2015 6:05:04 AM