What do you think about using XML to pass data between the server and the client?
This architecture is used on my current project and it works pretty well. Data is extracted from the db using its XML query functionality (supported by MS, Oracle and possibly others). There are no entity beans, only the session ones. All the methods of the session beans take as the parameter and return XML.
1. Client app requests data (eg person details). It calls Person.getPerson (ID)
2. Client app receives XML string containing all the relevant details about that person and populates its fields accordingly.
3. Client app updates the person details. It creates an XML string from the data in its fields and calls Person.updatePerson (xmlString) method.
- No entity beans and the performance problems associated with them
- Easy maintanability: If you want to add one more field to the form then you'll have to change the stored procedure that retreives the information and the client. No need to recompile the beans or the 'Data Objects'.
- Easy to represent complex tree-like structures with XML (eg master-detail).
- No need to write BMP Entitiy beans or initialise data objects from resultsets.
- Need to parse XML on the client which adds a little to the complexity of the client code
- The stored procedures' syntax is a bit convoluted in order for them to produce XML
- Business logic could be spread between the stored procs and the session beans, with most of it residing in the stored procs.
- Strong DB vendor tie-in
- Higher network bandwidth consumption
- Use of JAXB to automatically bind XML to java objects.
If done on the client side, then the XML received is parsed automatically. Potentially, could be used in the business objects tier instead.
Please let me know what's YOUR opinion on this approach.
PS This is a copy of the message posted earlier to the XML forum