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