You are not logged in.
Hi;
I newbie mormot and dephi.
I try to make a service based application.
I neeed to check parameters type and rules before processing
if parameters type is not compactible type send to client some error message instead of 406
if parameters check is pass process requested function?
for example ;
type
TServiceCalculator = class(TInterfacedObject, ICalculator)
public
function Add(n1,n2: integer): integer;
end;
function TServiceCalculator.Add(n1, n2: integer): integer;
begin
result := n1+n2;
end;
if a client call add function with string type I want to return to client some text about error.
But a clent call add function with integer params execute add function and function return result.
How can I do this. Does any body have any idea to solve this problem ?
thanks for all.
Offline
There is already some clue about the wrong parameter in the returned text error, IIRC.
One possibility could be to use a variant parameter, and check the explicit input type.
Or to use a method-based service.
Or to overload TSQLRestServer.OnAfterURI event.
But it is always easier (and safer) to rely on the client to be correct, and reject anything dubious.
Online
Another option is to create a TSQLRestRoutingREST to be used by the service and override the ExecuteSOAByInterface method to handle the error.
Using this approach, I can send a custom error and messagem on an interface-based service.
However, since you want to validate the type of data, it would be best to use method-based services.
Offline
Another option is to create a TSQLRestRoutingREST to be used by the service and override the ExecuteSOAByInterface method to handle the error.
Using this approach, I can send a custom error and messagem on an interface-based service.
However, since you want to validate the type of data, it would be best to use method-based services.
@macfly
Would you mind sharing some code showing how you did this? I think it might be a solution for one of my use cases because I also use an interface based service.
THanks,
JD
Offline