#1 2021-08-30 17:11:28

zakaria
Member
Registered: 2021-06-21
Posts: 26

Communication between mORMot2 and a legacy app

Hi all, i hope you are going great.
i have a problem in this situation as the following:

* i have a legacy application that runs under Delphi 7,
and need to communicate between them and new one developed with Delphi 10 (Because of compatibility with Hardware devices)

=>  depends of the example : "04-InterfacedBasedServices"
1 - Run (as Admin) the server side with Delphi10.4.
2 - Run (as Admin) the client side with Delphi 7.
all going great but when i put the name and the msg and click "add message" btn, this error was occurred:

TInterfacedObjectFakeClient.FakeCall(IExample.Add) failed: '{
"errorCode":406,
"errorText":"IExample.Add failed parsing ASample: TSample from input JSON"
}'

Specs:
Delphi7(32bits), Delphi 10.4(64Bits)
Windows 10 (64Bits)

Any Help Plz smile

Offline

#2 2021-08-30 17:56:22

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

Re: Communication between mORMot2 and a legacy app

How is TSample defined?

Ensure that the fields do match between Unicode and non-Unicode Delphi.

Online

#3 2021-08-31 14:24:12

zakaria
Member
Registered: 2021-06-21
Posts: 26

Re: Communication between mORMot2 and a legacy app

Hi, i resolved the problem with the following:
1 - Convert controls text values from Wide String to Utf-8 with "WideStringToUtf8" function.
2 -  add a writer serialization for the "TSample" record for D7.
code:

const
  __Tsample = 'Name, Question : RawUTF8;';
initialization
  TRttiJson.RegisterFromText(TypeInfo(TSample), __TSample,
    [jpoIgnoreUnknownProperty], []);
 Sample.Name := WideStringToUtf8(NameEdit.Text);
  Sample.Question := WideStringToUtf8(QuestionMemo.Text);

thnx for your quick answer and the great framework

Last edited by zakaria (2021-08-31 14:27:15)

Offline

#4 2021-08-31 19:00:31

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

Re: Communication between mORMot2 and a legacy app

Small note:
From VCL to mORMOt, you should rather use StringToUtf8() instead of WideStringToUtF8().

The VCL String is UnicodeString, not WideString.

Online

#5 2021-09-01 14:45:30

zakaria
Member
Registered: 2021-06-21
Posts: 26

Re: Communication between mORMot2 and a legacy app

Ok, Thanks a lot smile

Last edited by zakaria (2021-09-01 14:45:40)

Offline

Board footer

Powered by FluxBB