#2 mORMot 2 » Is there a size limit when passing parameters during interface func. » 2026-01-08 15:37:05

justin19770424
Replies: 2

This is modified from the sample.

api.interfaces.pas
------------------------------------
TProcessingResult = packed record
  ServerSyncTime: TDateTime;
  Msg: RawUtf8 ;
  ResultStatus:RawUtf8;
  ServerSyncVersion:RawUtf8;
  FailedTableNames: TArray<string>;
end;
TSyncDataItem = packed record
  ID: TID;
  TriggerType:RawUtf8;
  TableName: RawUtf8;
  OperType: Integer;
  SyncVersion: RawUtf8;
  SyncTime: TDateTime;
  DeleteFlag: Boolean;
  FieldValues: TJSONObject;
end;
PSyncDataItem=^TSyncDataItem;
TSyncDataItems = array of TSyncDataItem;

ILongWorkService = interface (IInvokable)
['{09FDFCEF-86E5-4077-80D8-661801A9224A}']
function SyncData (const items:TSyncDataItems): TProcessingResult; // 简化参数名称,避免冲突
end;
....
initialization
  Rtti.RegisterFromText(TypeInfo(TProcessingResult),
        'ServerSyncTime:TDateTime Msg:RawUtf8 ResultStatus:RawUtf8 ServerSyncVersion:RawUtf8 FailedTableNames: TArray<string>');
  Rtti.RegisterFromText(TypeInfo(TSyncDataItem),
        'id:TID TriggerType:RawUtf8 TableName:RawUtf8 OperType:Integer SyncVersion:RawUtf8 ' +
        'SyncTime:TDateTime DeleteFlag:Boolean FieldValues:TJSONObject');
   Rtti.RegisterType(TypeInfo(TSyncDataItems));
   TInterfaceFactory.RegisterInterfaces( [TypeInfo(ILongWorkCallback) , TypeInfo(ILongWorkService)] ) ;

Server Side:
---------------------------
function SyncData(const items:TSyncDataItems): TProcessingResult;
begin
    result:=ExecuteDataOperation(items);
end;

Client Side:
----------------------------
for J := 0 to 2 do
begin
   SetLength(Test, Length(Test) + 1);
   Test[High(Test)] := SyncDataItems[J];
end;
SyncResponse :=FClient.Service.SyncData(Test) ;

An error occurs when the client invokes the method: it works fine when the Test array has 2 elements, but throws an error when it has 3 elements. I don’t know the reason—could it be that there is a limit on parameter passing?  and this error occurs before the parameters are transmitted to the server program

Board footer

Powered by FluxBB