It's not a secret anymore!
The moose likes XML and Related Technologies and the fly likes xml vs DTO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xml vs DTO" Watch "xml vs DTO" New topic

xml vs DTO

ramesh kumaru

Joined: Sep 30, 2012
Posts: 2
Hi All,

Why is xml used to pass data between application layers? We can very well use DTO for same purpose.

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Welcome to the Ranch, Ramesh!

As for your question: you would have to ask the person who decided to do it that way why they made that decision. It's possible that it was a good decision, or that it was a bad decision, but without any details it's useless to speculate about it.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
My reasons for using XML instead of DTO etc

- easy to create/modify example data with a text editor so you can test data processing independently from data creation
... see for example the use of SOAPui to manipulate SOAP XML messages, especially for creating error conditions

- easy to read actual data transmissions - see SOAPui again

- easy to add new data elements without having to modify existing programming (assuming you chose a good structure in the first place.)

ramesh kumaru

Joined: Sep 30, 2012
Posts: 2
Thanks William and Paul,

In my application they have DTO and in each DTO they have marshalXML and unMarshalXML method/function which are used for xml generation.

This xml is passed to different layers including DAO layer. I am fail to understand why this architecture, instead they can use DTO itself and avoid overhead of Marshalling XML and UN-Marshalling XML.

Can you please provide some pointers, How this architecture benefits.

I agree. Here's the link:
subject: xml vs DTO
It's not a secret anymore!