I have a question about best practices. Let's say I have a web method that returns employee id and employee name. Now, since I am new to Web Service,we( client(C#) and I(Java)) agreed upon a return type List<String> and String format is "employee id,employee name". All is well so far. Program runs and it does the job.
Now, the other day, I was having conversation about return type with another developer and she suggested the way I am returning the data is not right instead I should return String in XML format so the typical output may look like (here without formatting),
I argued that, in this case, you're returning more than 50% non-data(XML tags) to client which is unnecessary. And she argued back that in case of unobvious scenarios like, user does not have permission to access something or there is nothing to return but the error code or something went wrong on server i.e when you need to return something else other than actual data itself, XML string is helpful since you can insert <error> tag. And it's a valid argument so can somebody with good experience with Web Service shed some light here?
The choice of XML as an output format has good and not so good implications:
Flexibility, if you decide to add new fields to the information returned, correctly written client software will not care and not even notice.
Documentation: with good tag names you will be able to understand what you were doing when you look at the project later.
Client side needs to parse XML - time consuming for huge data sets.
More bandwidth consumed - back in the days of 2400 baud dialup connections this might have been worrying, zipping an XML document can make a huge difference because of all the repeated tags.
Have to learn new tools - might actually be a plus depending on your employment goals