File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes XML as data transfer mechanism Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "XML as data transfer mechanism" Watch "XML as data transfer mechanism" New topic

XML as data transfer mechanism

Kalyan Mudumbai

Joined: Apr 30, 2004
Posts: 12
I have recently joined a team which has successfully implemented a high performing,robust 3-tier system, using Swing as a front-end, EJB as the middle-tier and Sybase as the data-tier.
The architecture uses XML as the data transfer mechanism between the presentation tier and the business tier. I always thought that it's better to use java objects to pass on the data from the 1st tier to the 2nd tier, because serialization of java objects is much quicker than serialization and deserialization of XML.
Experienced people, could you please put in your thoughts on this one?
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

You are absolutely right. Though you can use XML as your data transfer format, the importent point is that it doesn't really provide you any tangible benefits. Think about the extra work you are asking your application to do - for each remote call not only do you now have the overhead of the call to contend with, you must now create a Document, serialize it, transmit it, unserialize it and parse it into an new Document, deal with the message and possibly persist it through an ORM layer. The only possible benefit I can see from this route is if your business tier were third party and not within your control - in which case passing Documents which conform to a DTD could be helpful, with regards to keeping method signatures stable, which is straying towards a web services model. This would still be less performant though. And I can't think of any development team which could work like this.
XML in traditional J2EE aps (outside of webservices) in my opinion is best kept in the presentation layer. It is a valid thing to do to render a GUI using say XSLT, but in this case I'd use one of the many Object-to-XML utilities out there and do the work in you're swing client.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
Amen! I've ranted about this before here on Javaranch so it's good to hear someone else back up my "XML doesn't belong in the business layer" theme.

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
I agree. Here's the link:
subject: XML as data transfer mechanism
It's not a secret anymore!