You are not logged in.
Pages: 1
Hello, trying to implement first method service:
Server side
type TSQLRestServerDBTW = class(TSQLRestServerDB)
published
procedure ContactSearch(var Ctxt: TSQLRestServerURIContext);
end;
procedure TSQLRestServerDBTW.ContactSearch(var Ctxt: TSQLRestServerURIContext);
var SQL : RawUTF8;
zStr,
zFld : RawUTF8;
begin
zFld:='';
zStr:='';
if UrlDecodeNeedParameters(Ctxt.Parameters,'SearchStr,Fields')
then begin
while Ctxt.Parameters<>nil do
begin
UrlDecodeValue(Ctxt.Parameters,'SearchStr=',zStr);
UrlDecodeValue(Ctxt.Parameters,'Fields=',zFld,@Ctxt.Parameters);
end;
SQL:='select '+zFld+' from Contact WHERE Name='''+zStr+''' ORDER BY Name;';
Ctxt.Results([ServerForm.DB.DB.ExecuteJSON(SQL)]);
end
else Ctxt.Error('Missing Parameter');
end;
Client side
type TSQLHttpClientTW = class(TSQLHttpClient)
published
function ContactSearch(ASearchStr:String;AFields:RawUTF8):RawUTF8;
end;
function TSQLHttpClientTW.ContactSearch(ASearchStr, AFields: RawUTF8): RawUTF8;
var T : TSQLTableJSON;
begin
Result:=self.CallBackGetResult('ContactSearch',['SearchStr',ASearchStr,'Fields',AFields],TSQLContact);
end;
But when I run code from client, I get to server method, but on first line breakpoint, I see no Ctxt.fInput (most Inaccesible value) and Parameters='' so UrlDecodeNeedParameters gives AV.
The samples in manual is little different for 1.17. so am I even using the correct classes (TSQLRestServerDB & TSQLHttpClient) and the rest is also a bit cloudy still. :)
Regards
Offline
aha! Hybrid 1.17 & 1.18 code
Thanks.
Now I see Ctxt.Parameters as:
SearchStr=abc&Fields=ID....
But:
UrlDecodeValue(Ctxt.Parameters,'SearchStr=',zStr);
Does not fill in zStr.
Edit:
After looking at the code, I see I had to pass the parameter as UPPERCASE. Strange, no?
UrlDecodeValue(Ctxt.Parameters,'SEARCHSTR=',zStr);
Last edited by AntonE (2014-07-02 13:56:36)
Offline
Please rtfm http://blog.synopse.info/post/2010/07/1 … phi-7-2010
And download latest 1.18 SAD PDF.
Using input[] may be easier to you.
Online
Thank you for your kind words.
The manual as under the 'downloads' section is still 1.17
http://synopse.info/files/synproject/sampledoc.zip
But I see it further down
Last edited by AntonE (2014-07-02 18:22:17)
Offline
Go to http://synopse.info/fossil/wiki?name=Downloads and check out "Trunk/unstable version" paragraph.
you can get a daily snapshot of the repository directly from http://synopse.info/files/mORMotNightlyBuild.zip
Note that you will also need the SQLite3 .obj files from http://synopse.info/files/sqlite3obj.7z, since they are not part of this package.Direct download of the corresponding Synopse mORMot Framework SAD 1.18.pdf document is also available from http://synopse.info/files/pdf/Synopse%2 … 201.18.pdf
Ensure you check the ReadMe.txt pages!
Thanks for your feedback.
Online
Pages: 1