You are not logged in.
Pages: 1
Hi,
I would like to create a little server with the "Sum" fonction, as we can see in the Sample 06 but I would like to create a communication between a server on linux and a client on W7. So I'm searching an alternative to replace the function ExportServerNamedPipe.
Can I use a TSQLRestServer ?
Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits
Offline
Have a look at Sample 26 !
You will find all you need !!
Offline
Have a look at Sample 26 !
You will find all you need !!
Thank's !!!!!
Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits
Offline
" FileFromString(Ctxt.Call.InBody,FileName); "
RESTServerClass.pas(68,32) Fatal: Syntax error, ")" expected but "identifier INBODY" found
Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits
Offline
Add this:
unit RESTServerClass;
interface
{$I Synopse.inc} // <---- add this !!
uses
SysUtils,
Classes,
Offline
Add this:
unit RESTServerClass; interface {$I Synopse.inc} // <---- add this !! uses SysUtils, Classes,
Thank you. I'm sorry for all my questions but I'm new in the mORMot's world !
Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits
Offline
No problem !
Not all samples are out-of-the-box prepared for FPC / Lazarus / CodeTyphon.
But I am working on this.
(as an extra: preparingall command line samples to compile with IntelliJ)
But in general: you have to use {$MODE Delphi} for mORMot to work with FPC.
1) by changing the compiler settings
2) by adding {$MODE Delphi} to the source
3) by including Synopse.inc
Offline
Ok. It's a very good project for me and all the team is working very well to fix the mistakes.
Thank you for your councils !
Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits
Offline
I had the Sum function to the server and I create a button to do the calcul to the client (Sample 26). There are my codes :
Server :
type
// TSQLRestServerFullMemory kind of server is light and enough for our purpose
TServiceServer = class(TSQLRestServerFullMemory)
published
procedure Sum(Ctxt: TSQLRestServerURIContext);
end;
{ TServiceServer }
procedure TServiceServer.Sum(Ctxt: TSQLRestServerURIContext);
var a,b: double;
begin
if UrlDecodeNeedParameters(Ctxt.Parameters,'A,B') then begin
while Ctxt.Parameters<>nil do begin
UrlDecodeDouble(Ctxt.Parameters,'Nombre 1 :',a);
UrlDecodeDouble(Ctxt.Parameters,'Nombre 2 :',b,@Ctxt.Parameters);
end;
Ctxt.Results([a+b]);
end else
Ctxt.Error('Missing Parameter');
end;
Client :
procedure TMainForm.btn_calcClick(Sender: TObject);
//ajout de la somme
var a,b: double;
err: integer;
Note: TSQLNoteFile;
begin
val(edt_a.Text,a,err);
if err<>0 then begin
edt_a.SetFocus;
exit;
end;
val(edt_b.Text,b,err);
if err<>0 then begin
edt_b.SetFocus;
exit;
end;
if fClient=nil then
exit;
Note := TSQLNoteFile.Create;
try
lbl_res.Caption := UTF8ToString(fClient.CallBackGetResult('Sum',['A',a,'B',b]));
finally
Note.Free;
end;
end;
But the result is : 400 Bad Request. I used CommView to check if the client's connection to the server is working, it is. I think my problem is in the code but I don't see it ...
Last edited by Thomas-Acia (2015-04-22 08:03:58)
Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits
Offline
In your client code, you send variables "A" and "B" to server method "Sum":
fClient.CallBackGetResult('Sum',['A',a,'B',b])
In your server code, you decode "Nombre 1" and "Nombre 2" in method "Sum":
UrlDecodeDouble(Ctxt.Parameters,'Nombre 1 :',a);
UrlDecodeDouble(Ctxt.Parameters,'Nombre 2 :',b,@Ctxt.Parameters);
Try this in your server:
UrlDecodeDouble(Ctxt.Parameters,'A=',a);
UrlDecodeDouble(Ctxt.Parameters,'B=',b,@Ctxt.Parameters);
Offline
In your client code, you send variables "A" and "B" to server method "Sum":
fClient.CallBackGetResult('Sum',['A',a,'B',b])
In your server code, you decode "Nombre 1" and "Nombre 2" in method "Sum":
UrlDecodeDouble(Ctxt.Parameters,'Nombre 1 :',a); UrlDecodeDouble(Ctxt.Parameters,'Nombre 2 :',b,@Ctxt.Parameters);
Try this in your server:
UrlDecodeDouble(Ctxt.Parameters,'A=',a); UrlDecodeDouble(Ctxt.Parameters,'B=',b,@Ctxt.Parameters);
It was a stupid error. My method "Sum" was declared in the class "TServiceServer" and when I called the function I used the class "TSQLNoteFile"
Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits
Offline
Pages: 1