Solved

client - server data format

Posted on 2002-07-17
3
193 Views
Last Modified: 2010-03-31
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
Comment
Question by:jdaues
3 Comments
 
LVL 4

Expert Comment

by:pellep
ID: 7160998
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
 
LVL 3

Accepted Solution

by:
gandalf94305 earned 200 total points
ID: 7161024
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
 

Author Comment

by:jdaues
ID: 7172771
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now