Manage Web Service Views / Templates for Multiple Clients

I have a server side web service that serves multiple clients. Clients include web browsers, iPhone, BlackBerry, Android, etc. My question is that I need to be able to generate dynamic content for these clients to view. Whether it's a full blown HTML template, HTML snippet, JSON, XML, etc. Depending on the requesting client's user agent, a different "view" template is created and preempted by the web server.

My question is, are there some elegant "views" or styles to adapt to make it easier to manage all these snippets / fragments / full templates in some ordered order? I was looking for an elegant way to manage this myriad of customer transactions, with direct service and easy debugging for UI developers.

0


source to share


3 answers


You need a clear separation between model and presentation. If you write multiple generic components that extract data from an agnostic view (model), you can have multiple adapters that display the output for each specific purpose ("Views"). There are frames around that tie it all into one big package; They are usually referred to as MVC-framework . But you really don't need it if it's not to your liking. For most kinds of output, you can use the templating engine to help you write views. For material that is a more non-interpretive presentation, such as JSON or XML, and general output that is meant to be consumed by the computer, you would probably use something else to generate the output.



+1


source


I think you are looking for a templating engine. I have been using Smarty for a long time and I really like it. This creates a separation between logic and page design. All you need to do is download the template file for the user agent who made the request. The rest of the logic will remain the same.



http://www.smarty.net/

0


source


First of all, you shouldn't be returning HTML via webservice. IMHO the web service should return a generic / client independent form. I would suggest using a simple ASPX web page that receives multiple XSL layout transformations for some clients.

Make it customizable and you won't have to touch the code for a long time, even if new clients appear or your visualization changes.

-2


source







All Articles