You are not logged in.
Pages: 1
In DataSnap, I have a server method "Sum" that accept two parameters "a" and "b", user may enter some numbers and Sum method will return a sum of that numbers.
function TMyServerMethod.Soma(const a, b: integer): integer;
begin
Result := a + b;
end;
Indeed, it is very simple to work with DataSnap server methods. You can consume these services methods, implemented Server-Side in fast Delphi code, with any AJAX application Client-Side.
In mORMot, is a little different, as you can see below:
procedure TServiceServer.Soma(var Ctxt: TSQLRestServerCallBackParams);
var a,b: Extended;
Begin
if UrlDecodeNeedParameters(Ctxt.Parameters,'a,b') then begin
while Ctxt.Parameters<>nil do begin
UrlDecodeExtended(Ctxt.Parameters,'A=',a);
UrlDecodeExtended(Ctxt.Parameters,'B=',b,@Ctxt.Parameters);
end;
Ctxt.Results([a+b]);
end else
Ctxt.Error('Missing Parameter');
end;
Call method from the URI in mORMot is something like:
http://localhost:777/service/Soma?a=10&b=20
Call method from URI in DataSnap is something like:
http:/localhost:8080/datasnap/rest/TServerMethods1/Soma/10/20
I'd like to do some similar do DataSnap technology in mORMot.
Thank you.
Last edited by warleyalex (2013-01-29 19:39:20)
Offline
You can use an interface based service, or use the upcoming version 1.18 which makes working with parameters much easier.
See http://blog.synopse.info/post/2010/07/1 … phi-7-2010
See also the 1.18 Documentation SAD pdf http://synopse.info/files/pdf/Synopse%2 … 201.18.pdf
Offline
Pages: 1