Converting RODL-based to code-first

In the RODL file we used the AnsiString type as parameter. Now we wanted to convert this RODL to code-first (c#, .net6). How can we make the code-first server to work correctly with existing Delphi clients? We are using the newest ROSDK 10.0.0.1559.

Thanks for any help.

Hi,

use StreamAs attribute

        [RemObjects.SDK.StreamAs(RemObjects.SDK.StreamingFormat.AnsiString)]
        public virtual string NewField {
...

read more at Defining Code-First services (.NET)

note: you can generate _Intf from .RODL and see how it will be generated.

Hi Evgeny

thank you for your fast answer. I tried both code-first with StreamAs(StreamingFormat.AnsiString) and creating the server with RODL and *_Impl.cs. Neither works.

I’m using IpSuperTcpChannel and BinMessage.

I made a simple Delphi client and implemented the Login-Method with both string parameters as AnsiString. When I send ‘abcüdef’ as the username-string, I see in the Wireshark-log the bytes 0x61 0x62 0x63 0xFC 0x64 0x65 0x66. But in the Login function in the server (LoginService_Impl.cs) I receive the string ‘abc?def’

ROLoginClient.zip (3.8 MB)
ROLoginServer.zip (1.4 MB)

What I’m doing wrong?

Kind regards, Peter

Hi,

we use

public static String StringFromBuffer(Byte[] buffer, Encoding encoding)
{
	return encoding.GetString(buffer, 0, buffer.Length);
}

where encoding is System.Text.Encoding.ASCII.


according to https://learn.microsoft.com/en-us/dotnet/standard/base-types/character-encoding:

as a result, your 0xFC char is lost.

also they recommend:

Hi Evgeny

Ok, I understand. So is it possible to use BinMessage with Encoding.Latin1? Or to derive from BinMessage an create my own BinMessageWithLanin1 class to use it with the server?

    public class BinMessageLatin1 : BinMessage
    {
        public BinMessageLatin1() : base() 
        {
        }

        protected override void InitializeSerializer()
        {
            _serializer = new BinSerializer(Encoding.Latin1);
        }
    }

It’s only for backward compatibilty. I’ve to replace the server first an then update the clients. The new Delphi clients can deal with utf-8.

Hi,

better to use

    public class MyBinMessage : BinMessage
    {
        public override IMessage Clone()
        {
            MyBinMessage clonedMessage = new MyBinMessage();
            clonedMessage.CloneFrom(this);
            clonedMessage.DefaultStringEncoding = this.DefaultStringEncoding;
            return clonedMessage;
        }
    }
..
            BinMessage binMessage = new MyBinMessage();
            binMessage.DefaultStringEncoding = Encoding.Latin1;

I’ll review why DefaultStringEncoding value isn’t copied at cloning.

1 Like

Logged as bugs://D19343.

bugs://D19343 was closed as fixed.