0
votes

I migrated a Datasnap server to XE 10.1 Berlin and now I get an error on the server when I invoke a servermethod with OUT parameters.

Object

  TBtwlControlePar=class
    xInDoc,
    xHandmatig,
    xStatus,
    xVerwacht,
    xAantal,
    xVerwerkt,
    xOnVerwerkt,
    xOnverwerktInDocument,
    xTotaalCustoms :Integer;
  end;

function TPWAdminMethods.DOC_BTWAH_Get2(pPeriode, pMaand, pSort,pSelop,pSelOntvangen,pSelToegewezen,pSelVerwerkt: integer; pSel: string; out pControlePar: TBTWLControlePar): TResult;

ServerMethod

tmpM := TPWAdminMethodsClient.Create (DMForm.DSConnection.DBXConnection, false);

Client

  FreeAndNil( fControlePar );
  tmpResult := tmpM.DOC_VATLH_Get2(Jaar,sort,SelOp,SelOntvangen,SelToegewezen,SelVerwerkt,fSelection,fControlePar);          

When this method is fired the server gives an error on this last line

procedure TDSMethod.Invoke(MethodInstance: TObject;
  MethodValues: TDSMethodValues);
var
  RContext: TRttiContext;
  RType: TRttiType;
  Params: TArrayOfTValue;
begin
  Params := MethodValues.GetValues;
  RType := RContext.GetType(MethodInstance.ClassType);
  MethodValues.ReturnValue := RType.GetMethod(FMethodInfoHeader.NameFld.ToString).Invoke(MethodInstance, Params);
end;

VAN and OUT argument must match parameter type exactly

Is it impossible to use out parameters in Delphi Berling Datasnap without the use of DBXJson?

1
Are you sure that you use the same declaration for the class - not only a similar? - Uwe Raabe
Yes, the problem also happens with a TStream object for example. - r_j
If you don't mind losing type safety you can simply change the out parameter to a pointer and do the conversion. After the conversion to TObject, do an is to check it's really the class you need it to be and then you can safely hardcast it to TBtwlControlePar - Johan

1 Answers

1
votes

This error message and the issue has been logged on Embarcadero's Quality Portal as RSP-14895. This was on 16May16 by someone else. That person stated "XE10 is OK". Today (14Jun16) I added another test project to the issue. My test project is for the case of a VAR parameter. I have also provided a screenshot of the test project in action. My tests work on XE6 but fail on 10.1 Berlin. I can't use DataSnap until this issue is fixed. Please vote up the issue.