.NET client methods return null against Delphi server using /json

We have a new .NET client that is calling methods on a Delphi server over the Remoting SDK. When using the /bin endpoint, our client deserializes responses correctly. However if we use the /json endpoint, the properties in the response are populated with null values. The following client code was generated automatically using the extension for Visual Studio 2022:

        public virtual ResultLogin EndLogin(System.IAsyncResult ___asyncResult) {
            RemObjects.SDK.IMessage ___localMessage = ((RemObjects.SDK.IClientAsyncResult)(___asyncResult)).Message;
            try {
                ResultLogin Result = ((ResultLogin)(___localMessage.Read("Result", typeof(ResultLogin), RemObjects.SDK.StreamingFormat.Default)));
                return Result;
            }
            finally {
                this.___ClearMessage(___localMessage);
            }
        }

ResultLogin is a ComplexType, and is correctly populated when using the /bin endpoint. However all the properties are null when using the /json endpoint. I’ve used Wireshark to observe that the JSON response is being received by the client, and it appears to match well with the serializable classes.

Before I embark on a potentially painful process to create small client/server test apps (I don’t currently have Delphi), is there anything I should try, or anything you can think of that may shed some like one why I’m seeing this?

I’m using RemObjects.SDK 10.0.0.1549 on the client, and I’d have to get back to you with what version is running on the server (though it should be reasonably up-to-date).

Many thanks,
Dave

My apologies for the delay on this issue, but my colleague Eugene is out of office today; he will try his best to get back to you, tomorrow.

If you have tried/can try, does a Delphi client process the response correctly from the same server, when using the /json endpoint?

Hi,

we have fixed some issues with JSON deserialization in .1553 in .NET code.
it was related to datetime, boolean and number values.
if you are used these types in your ResultLogin struct, better to use .1553
this will be compatible with .1549 Delphi server.

It is better to have a simple testcase that reproduced your issue.
it will be difficult to reproduce this issue w/o your testcase.

Hey guys. Thanks for the suggestion! I’ve updated the .NET client to 1553 but unfortunately I get the same result. I’ll work on some suitable tests and get back to you.

1 Like

With regard to trying a Delphi client; I now have a MyLibrary.remoteRODL that contains a ServerUri ending in /json. The ServerAccess TDataModule generated from this contained a TROBinMessage, which didn’t seem to work very well against the JSON endpoint (it did work against the /bin endpoint). I replaced this with a TROJSONMessage, and I can now see the JSON response coming back from the server in Wireshark, but again, even in the Delphi client, the response properties are not populated (contains nils).

Was manually replacing TROBinMessage with a TROJSONMessage the correct thing to do to the client code against a JSON server, and are there any other steps I may have missed that would result in the nils?

Hi,

You are right, ServerAccess unit is generated with BinMessage.

in code, you can avoid using ServerAccess and just use something like

lservice := CoNewService.Create('http://localhost:8099/json');
Channel.TargetUrl := 'http://localhost:8099/json';
lservice := CoNewService.Create(JSONMessage, Channel);

or just replace BinMessage with JSONMessage in ServerAccess unit


Can you share this response, pls?
You can drop email to support@ for keeping privacy


Edit: TROJSONMessage is supported in ServerAccess from next build.

Hi,

Check that JsonMessage.WrapResult on client-side is set to True

That fixes it for the Delphi client, thank you! Is there an analogous property for the C# client?

Hi,

check above link - it’s API for Remoting SDK for .NET

Ok thank you. It wasn’t obvious to me that the IMessage exposed in the C# client ServerAccess code was in fact the JsonMessage you were referring to. I have added the following to the ServerAccess constructor and it seems to work ok.

        if (_message is not null && _message is JsonMessage)
        {
            ((JsonMessage)_message).WrapResult = true;
        }

I’m happy with this resolution, but please let me know if there is a better way to do this!
Thank you for your support :+1:

Hi,

pls review our samples, e.g. HTTP Chat sample (.NET)

it has this code

            // 
            // jsonMessage
            // 
            this.jsonMessage.ContainsData = false;
            this.jsonMessage.ContentType = "application/Json";
            this.jsonMessage.CurrentObject = null;
            this.jsonMessage.Id = null;
            this.jsonMessage.SerializerInstance = null;
            this.jsonMessage.SessionIdAsId = true;
            this.jsonMessage.WrapResult = true;

Note: this sample doesn’t use ServerAccess unit

1 Like