You are not logged in.
Pages: 1
Okay, thanks.
If I use interface, could I use restful?
I tried receive via TSQLRestServerURIContext, but not allow.
I need receive the data via POST/PUT (Ctxt.Call.InBody), but I do not found how do.
Could you give me some tip of how do?
Please, sorry me by my english.
Thanks for your reply.
I do not know what the class and the method will depend on the parameter.
http://localhost:777/restSF/ObjectJson/?NameClassController=CfopController.TCfopController&NameMethod=Consult&Parameters=id=1|1|True
procedure TServiceServer.ObjectJson(Ctxt: TSQLRestServerURIContext);
var
Context: TRttiContext;
RttiInstanceType: TRttiInstanceType;
parameters: TArrayParameters;
pNameClassController: String;
pNameMethod: String;
pParameters: String;
return: TExtjsVO;
begin
try
if UrlDecodeNeedParameters(Ctxt.Parameters, 'NameClassController') then
begin
pNameClassController := Ctxt.InputString['NameClassController'];
pNameMethod := Ctxt.InputString['NameMethod'];
pParameters := Ctxt.InputString['Parameters'];
end;
Parameters := MountParameters(pParameters);
RttiInstanceType := Context.FindType(pNameClassController) as TRttiInstanceType;
return := TExtjsVO(RttiInstanceType.GetMethod(pNameMethod).Invoke(RttiInstanceType.MetaclassType, Parameters).AsObject);
if Assigned(return ) then
begin
Ctxt.Returns(ObjectToJson(return , []));
FreeAndNil(return);
end;
Ctxt.success;
finally
Contexto.Free;
end;
//
end;
There are several classes (TPersistent) and through the rtti will perform to called the Class/Method according with parameters.
Now, can you understand?
The following detailed example.
class function TCfopController.Consult(pFilter, pPage: String; pComplete: Boolean): TExtjsVO;
var
objReturn TExtjsVO;
begin
objReturn := TExtjsVO.Create;
objReturn.success := true;
objReturn.total := 1;
objReturn.rows := 'It is Okay, worked. [TCfoController]';
result := objReturn;
end;
Other exemple
http://localhost:777/restSF/ObjectJson/?NameClassController=CustomerController.TCustomerController&NameMethod=Consult&Parameters=id=1|1|True
class function TCustomerController.Consult(pFilter, pPage: String; pComplete: Boolean): TExtjsVO;
var
objReturn TExtjsVO;
begin
objReturn := TExtjsVO.Create;
objReturn.success := true;
objReturn.total := 1;
objReturn.rows := 'It is Okay, worked. [TCustomerController]';
result := objReturn;
end;
The code works perfectly with the consumption of a client, but when testo with two clients (threads) on, begin to occur error.
What can I change to no longer the error occurs?
Hello,
I am testing mormot (mORMotNightlyBuild 2015-08-01).
If apply the RttiInstanceType.GetMethod to execute the method is generated exception of more 30% of the requisitions when executed with more of instance.
//... The class name and method are sent via parameters. Ctxt.InputString['NameClasseController'] ...
RttiInstanceType := Contexto.FindType('CfopController.TCfopController') as TRttiInstanceType;
return := TExtjsVO(RttiInstanceType.GetMethod('Consult').Invoke(RttiInstanceType.MetaclassType, MyParameters).AsObject);
//...
But if execute without the RttiInstanceType is not generated exception.
return := TExtjsVO(TCfopController.Consult('id=1', '1', True));
Please This is a problem in rtti or mormot?
Thanks
Pages: 1