Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

client - server data format

I am writing a client-server java program.  It will read XML data files on the user's computer, then send the data to the server.  

Question 1:
It seems I could either:
Have the client read the XML files, bind it to java objects and then send the objects to the server

or:
Have the client read the XML files, send the XML to the server and have the server bind the XML to java objects

Which is usually done? why?

Question 2:

The choices for XML data binding (reading XML from a file and putting that data in java objects) appear to be JAXP, Castor, and Zeus.

What are the strengths and weaknesses of each?  Why would I choose one over the other?
0
jdaues
Asked:
jdaues
1 Solution
 
pellepCommented:
I'd advise to send the XML to the server and then parse it server-side. That way, if the XML structure changes, you won't have to update all the clients, just the server. I try to go by the rule 'as little intelligence in the client as possible'.
0
 
gandalf94305Commented:
I recommend simply passing the XML on to the server. The extra mapping of XML to Java objects and then serializing them to send data to the server does not make sense on the client, unless you need to perform any operations on the XML data that only the client can perform.

The disadvantages of parsing XML on the client side are
- you need a more heavy-weight client
- it will cost performance on the client
- for network transfer you have to serialize objects, anyway.
- you don't have to care what the server is written in (Java, Perl, C, C++, ...)

If you are concerned about bandwidth, compress the file using zip or jar format.

If you are concerned about security, sign the file (compressed or clear text) on the client.

For transmitting the actual data, you may want to consider SOAP (see http://jakarta.apache.org).

On the server, use your favourite mapping tool or don't. In my experience, automatic mapping is not as efficient as hand-coded mappings. Very often, it is fairly easy to traverse an XML structure and build a rather simple Java structure from it. This is getting even more important if you use an object-relational mapping for persistent data on the server. On the other hand, if you use an XML database (check out http://jakarta.apache.org or http://sourceforge.net), you don't really care because you can store and retrieve XML natively.

Personally, I view XML-based notations as interchange formats, not representation formats, i.e., it is nice to have a vendor-, platform-, operating-system- and hardware-independent syntax but such independent beasts are rarely efficient enough as internal data structures in a performant application.

Cheers,
--gandalf.
0
 
jdauesAuthor Commented:
Ok, parse on the server side.

As far as mapping, I think that hand-coding is not a practical solution for me as there will be numerous schema.  I am leaning towards Zeus at the moment.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now