#1 2017-08-03 07:52:07

dka1
Member
From: Greece
Registered: 2017-07-25
Posts: 28

Can't get result/out parameters from callback interface

Hello ab,
working with callback interface I tried to return value from a function OR an out param from a procedure.
Both of tries result error failed: unexpected parameter "result"

  ISpotCallBack= interface(IInvokable) 
  ['{F8D9E6D3-F435-4C06-923A-9B7D12BBE2E6}']
    procedure IsOk(a: Integer; out b: Boolean);
    OR
    Function IsOk(a: Integer): Boolean;
  end;

From server's error log

20170803 07263359  ' EXC   EInterfaceFactoryException {"Message":"TInterfacedObjectFakeServer.FakeCall(ISpotCallBack.IsOk) failed: unexpected parameter \"result\""} at 004FC9BF mORMot.RaiseError (32126)  stack trace API 004FC9BF mORMot.RaiseError (32126) 004FCDCF mORMot.InternalProcess (32126) 004FD53D mORMot.TInterfacedObjectFake.FakeCall (32126)

Digging on mORMot client code

procedure TSQLRestClientURI.InternalNotificationMethodExecute
...
      WR.AddShort('{"result":[');
      if frames='[0]' then // call before the first method of the jumbo frame
        Call(callback.Factory.MethodIndexCurrentFrameCallback,frames,nil);
      Call(methodIndex,Ctxt.InBody,WR);
      if ok then begin
        if Ctxt.OutHead='' then begin // <>'' if set via TServiceCustomAnswer
          WR.Add(']','}');
...

found that build a json  {"result":[true]} that is not acceptable on server side code

function TInterfacedObjectFake.FakeCall(var aCall: TFakeCallStack): Int64;
...
        smvBoolean..smvWideString: begin
          Val := GetJSONField(R,R,@wasString,nil,@ValLen);
...

GetJSONField retrun nil

Can you help?

Offline

#2 2017-08-03 08:17:42

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

Re: Can't get result/out parameters from callback interface

My guess is that your client service routing/marshalling options do not match server side.
Both side should share the same routing and JSON layout.

Online

#3 2017-08-03 08:36:44

dka1
Member
From: Greece
Registered: 2017-07-25
Posts: 28

Re: Can't get result/out parameters from callback interface

I do not know how to change routing but debugging the app and see that both client/server use
TSQLRestRoutingREST.

Is something that I miss?

Offline

#4 2017-08-03 08:59:38

dka1
Member
From: Greece
Registered: 2017-07-25
Posts: 28

Re: Can't get result/out parameters from callback interface

I change Project31 / LongWorkServer / LongWorkClient and add a callback function with result integer and I get the same error
"missing or invalid value" .
Correction "unexpected parameter" get when call a procedure with out/var parameter
Is callback interfaces supporting functions or var/out parameters?

Offline

#5 2017-08-03 12:39:21

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

Re: Can't get result/out parameters from callback interface

I guess there is something wrong somewhere.

My idea was that it was tested in TTestBidirectionalRemoteConnection.TestCallback method, but in fact, it appears that it was not the case!
I will check again, and turn back here.

Online

#6 2017-08-03 18:05:02

dka1
Member
From: Greece
Registered: 2017-07-25
Posts: 28

Re: Can't get result/out parameters from callback interface

I run "TestSQL3" tests and I add a breakpoint on procedure TSQLRestClientURI.InternalNotificationMethodExecute
line 36685

 WR.AddShort('{"result":[');

When execution passed there are three methods

ServiceRecordVersionCallback.Deleted
ServiceRecordVersionCallback.Updated
BidirCallback.AsynchEvent

all three methods do not have return or var/out parameters.
I think there is a problem or not supported callback with functions Or var/out parameters.

Please take a look because I try all day and I can't find a solution.
Take as a reference LongWorkServer/client demo and add a callback with functions Or var/out parameters.

Offline

#7 2017-08-06 14:55:30

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

Re: Can't get result/out parameters from callback interface

Please check https://synopse.info/fossil/info/2eb7a6543e

Should be fixed now.
I've also enhanced the regression tests to cover this feature.

Online

#8 2017-08-08 05:31:02

dka1
Member
From: Greece
Registered: 2017-07-25
Posts: 28

Re: Can't get result/out parameters from callback interface

Thank you Arnaud.
I will try it today

Offline

Board footer

Powered by FluxBB