#1 2014-07-02 10:44:10

AntonE
Member
Registered: 2012-02-03
Posts: 74

Method SOA in 1.18

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

#2 2014-07-02 12:42:10

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Method SOA in 1.18

The method signature sounds wrong.

There should be no "var" any more!

Online

#3 2014-07-02 12:56:51

AntonE
Member
Registered: 2012-02-03
Posts: 74

Re: Method SOA in 1.18

aha! Hybrid 1.17 & 1.18 code big_smile
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

#4 2014-07-02 15:10:16

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Method SOA in 1.18

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

#5 2014-07-02 18:20:45

AntonE
Member
Registered: 2012-02-03
Posts: 74

Re: Method SOA in 1.18

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

#6 2014-07-02 19:45:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Method SOA in 1.18

Go to http://synopse.info/fossil/wiki?name=Downloads and check out "Trunk/unstable version" paragraph.

Download page wrote:

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

Board footer

Powered by FluxBB