Custom DA Delphi Server - Code First

Hello,

I ran the DA new app wizard and created a new DA custom server in Delphi. The base template code works well until I try to convert the app to a code-first server. The first problem I had was in LoginService_Impl.pas . When I tried compiling I got the following error:

[dcc32 Error] LoginService_Impl.pas(103): E2250 There is no overloaded version of ‘RegisterCodeFirstService’ that can be called with these arguments

that was caused by this line in the initialization section of the unit:

RegisterCodeFirstService(TLoginService); // fake declaration for RTTI

After commenting out that line I was able to compile. However, I cannot get any clients to connect to the custom server. Even the new client wizard cannot connect to the server. I get the following error:

Cannot retrieve server Schema:
RemObjects.SDK.Types.ServerException: An exception occurred on the server: Error reading parameter aLoginString: Stream read error at RemObjects.SDK.Messa…

Are code-first DA servers possible? Any suggestions as to what is wrong or where to look?

BTW: YES I am using the latest version of DA/Delphi and I am using the latest version of RADStudio 10.2 Tokyo Enterprise.

TIA,

Matthew Vesperman

Some errors during converting of existed service to CodeFirst were present.

RegisterCodeFirstService(TLoginService); // fake declaration for RTTI
pls add uRORemoteDataModule into uses section of LoginService_Impl.pas.

DA services weren’t converted correctly :frowning:
in this case, LoginEx should be declared as:

    [ROServiceMethod]
    function LoginEx([ROSerializeAsUTF8String]const aLoginString: String): Boolean; override;

I’ve added working a DA Code-First project.
You can use it as template for your application until it was fixed in DAD code

testcase.zip (112.2 KB)

Thank you,

Those changes did fix the two issues I had with the converted code.

Unfortunately I now have a new error when connecting.

Cannot retrieve server Schema:
System.Xml.XmlException: Name cannot begin with the ‘.’ character. hexadecimal value 0x00.
Line 1, position 2. at System.Xml.XmlTextReaderImpl.Throw(Excep…

Any suggestions on this one?

Also, where can I log some other minor bugs I have found?

Thanks,

Matthew

try to add shared.zip (4.1 KB)
into your delphi server-side project as

{$R shared.res}

it may solve this problem.

you can report about bugs here or post it to support@

Unfortunately that did not fix the issue. I still have the same error. :frowning:

As for some bugs I found, the first is that the initial template created has the following methods defined in TLoginService:

procedure LoginServiceLogin(Sender: TObject; aUserID,
aPassword: Utf8String; out aUserInfo: UserInfo;
var aLoginSuccessful: Boolean);
function LoginEx(const aLoginString: Utf8String): Boolean; override;

These should be:

procedure LoginServiceLogin(Sender: TObject; aUserID,
aPassword: String; out aUserInfo: UserInfo;
var aLoginSuccessful: Boolean);
function LoginEx(const aLoginString: String): Boolean; override;

Also, in the implementation for TLoginService.LoginServiceLogin there is a line that is defined as:

aUserInfo.SessionID := UTF8String(GuidToAnsiString(ClientID));

This should be:

aUserInfo.SessionID := ClientID.ToString;

Here is another issue when I try to do a build on my converted app.

[dcc32 Warning] uDACRLabsUtils.inc(58): W1058 Implicit string cast with potential data loss from ‘string’ to ‘AnsiString’

Unfortunately that did not fix the issue. I still have the same error. :frowning:

does your client has _Intf? it yes, you need to recreate it.

As for some bugs I found, the first is that the initial template created has the following methods defined in TLoginService:

template was already fixed.

[dcc32 Warning] uDACRLabsUtils.inc(58): W1058 Implicit string cast with potential data loss from ‘string’ to ‘AnsiString’

Thx, I’ll review it

Is the fix suppose to be in the current release, or is it in a newer upcoming release? The reason I ask is that I am using the latest version of DA/Delphi and the template as supplied is currently broken.

Thanks

The only _Intf listed in the server project (in any code file) is DataAbstract4_Intf

the fix will be present from the next beta

what platform you are using for client-side? .NET?

Thank you for the info.

I am using Delphi for everything at the moment. And the issue is when using the client template wizard. I haven’t even gotten to the point of having a client. (I am trying to create a separate client project to learn how that process works.) I have not yet tried the one created when the server was created.

you can use provided client.
after adding new datatables to server-side, you can add them to client-side via Create DataTables...:

When I try that with the already created client module I get the following error:

have you copied code from my testcase to your server like

    [ROServiceMethod]
    [ROSerializeResultAsUTF8String]
    function GetSchema([ROSerializeAsUTF8String] const aFilter:String): String;
...

?

No I did not. I will give that a try next.

Copying the contents from your test case’s DataService_Impl.pas file has fixed my server issues.

The convert to code-first menu item obviously is not converting everything that is needed for a DA code-first server. Is there a fix planned for that in the future?

Thanks,

Matthew

yep, it is planned.
the fix with

    [ROServiceMethod]
    [ROSerializeResultAsUTF8String]
    function GetSchema([ROSerializeAsUTF8String] const aFilter:String): String;
...

[ROServiceMethod]
function LoginEx([ROSerializeAsUTF8String]const aLoginString: String): Boolean; override;

was already merged into main trunk and will be in next beta

Thanks, this will work for now.

Any idea when the next beta is so I can help test it?

I think, it will be in one week.
I can send to you changed files so you can recompile DA_Server package manually and test it w/o waiting

Sounds good.