Datasnap Rest Windows Client writes

Source: Internet
Author: User

First of all, the datasnap of the XE about the information is really too little ...

The server uses the DSHTTPService1 control to implement HTTP interface invocation, which returns JSON-formatted data for cross-platform parsing.

It is emphasized here that the Datasnap HTTP method is called by default, and if you use post, you need to add the update to the TServerMethods1 cell before the method is not a good way.

Let's talk about it here. If the interface has parameters, the delivery format is interface name/parameter 1/Parameter 2/..., for example: http://127.0.0.1:8080/datasnap/rest/TServerMethods1/Interface name/tom/ Jerry

In addition, if the parameters have Chinese words need to encode the parameters, with the Tiduri.paramsencode method can be.

After the client invokes the interface, the JSON data returned by the DATASNAP middleware is encoded in Chinese and the client continues to encode it with JSON.

The client invocation example is as follows:

procedureTform2.button1click (sender:tobject);varLrlt:tstringstream; S,lurl:string;    Jo:tjsonobject; I:integer;beginLRLT:= Tstringstream.Create("'); TryLurl:=Edturl.text; Lurl:= Lurl + Tiduri.paramsencode ('/name/ Ah ah ah');    Idhttp1.get (LURL,LRLT); JO:= Tjsonobject.parsejsonvalue (TEncoding.UTF8.GetBytes (LRLT. datastring),0) asTjsonobject; //returns the number of table fieldsI: = Tjsonarray (Tjsonobject (Tjsonarray) (Jo. GetValue ('result')). items[0]). GetValue ('Table')).    Count;  MMLOG.LINES.ADD (IntToStr (i)); finallyLRLT.  Free; End;End;

Datasnap Rest Windows Client writes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.