Click here to Skip to main content
15,909,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my company someone implemented a remote object (2 different channels one HTTP and TCP) for interprocess comunication, this remote object have just an Execute method with 2 parameters: ActionName and Parameters.

ActionName is an enum type defining the Action to be executed at the server.

Parameters is an String (that usually contains objects serialized using xml to string)

The return type of the Execute method is an String (and again, usually contains objects serialized using xml)

The serialization method used is a custom one described in an interface the object has to implement it and it's usually a creation of an XmlDocument, and adding a node for the current object, if the object has a relationship with other objects it is appended as a new node to the existing XmlDocument, it can be an array of objects, and then it is converted to an string.

The objects serialized are usually POJOS, just models from the database, with accesors to set and get the model attributes.

So with this we can pass objects to the server as parameters and the server can return objects serialized.

My question is if there isn't a better way to pass objects from both sides?

There is an overhead of serializing and deserializing the parameters and the return responses.

The server usually sends objects instantiated from the database and then they are serialized and sent to the client.

I think that serializing and deserializing is hitting hard our performance, sometimes the response is big (an array of N-objects serialized) and takes time, the client doesn't have a way to track how much time the response would take.

Even if the server and client are on the same machine they use the same method, there has to be a better way to exchange information locally.

I think that I described very well our situations, any help or insights would be really appreciated.
Posted

Well, Binary Serialization is usually faster than XML Serialization but there would still be the problem of building the structure again on deserialization.

With XML Serialization there is the possibility, depending on your data, to use DataSets/DataTables both of which have ReadXML and WriteXML methods which I think would be faster than XMLDocument, and also more useful in further processing, Once again, though, it does depend on your data.

Just a couple of thoughts.
 
Share this answer
 
Custom XML serialization can be efficient if done correctly. Firstly it would be better to impliment it with a XmlReader/XmlWriter rather than an XmlDocument especially for large responses.

For communication on the same machine implementing a Named Pipe transport could help speed things up if your version of the framework supports it.

For slightly more advanced solutions as you run everything through a single method call it would be fairly easy to implement compression which would help for large responses and if you use reflection in your serialization take a look at the HyperDescriptor article on code project which uses Reflection.Emit to provide faster access to reflected properties.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900