Question

I wonder if it is possible to let a Java-Client communicate with a server that is written in C# with .NET.

On Wikipedia it says:

"At the client end, any requests to the remotable object are proxied by the .NET Remoting runtime over Channel objects, that encapsulate the actual transport mode, including TCP streams, HTTP streams and named pipes. As a result, by instantiating proper Channel objects, a .NET Remoting application can be made to support different communication protocols without recompiling the application."

That is why I assume that it should be possible for a Java-Application to connect to ServerIP:Port and exchange even complex object via TCP channel.

The question is if there is a library that could convert the received data back to a valid Java object?

Or is there another better way?

Any help would be great. Thank you!

Stefan

Was it helpful?

Solution

You can't directly load a complex Java object into .Net or vice versa, but you can have equivalent objects in both the client & server, and leverage JSON (as shown in bas' answer) to serialize & transport these objects across your channel.

This means when an object is sent from A -> B, it goes through the following sequence:

  1. Seralize from managed object in A into JSON
  2. Send JSON over transport channel from A -> B
  3. Recieve JSON object as a string at B
  4. Deseralize the object into a managed object for use by B

Steps 1 & 4 are where something like the NetwonSoft Json.Net library will be a great help for you. Any network protocol can tranport JSON objects along the wire.

OTHER TIPS

you could send and receive data with JSON or XML format

JSON for C#: http://james.newtonking.com/pages/json-net.aspx

JSON for Java: http://json.org/java/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top