How to be a good web service? Globalization
Web service globalization is a barely touched topic in academia. Yet it is highly interesting from business perspective because globalized web service can be scaled to different countries with relatively low cost. Having gone through a few web service globalization projects myself, I feel relieving while writing this blog.
A. What needs to be globalized?
1. The request and response should be able to handle unicode. The URL and the header of the HTTP request are typically ascii, if you have to put unicode there, those unicodes need to be base64 encoded then escaped.
2. The request should have global awareness.
Somewhere in the request, there should be a place to specify the locale of the request, it can be a part of the query string, a header, an element or an attribute in the request. With a specified locale, the server can get to know the source of the request, thus responding appropriately.
3. The response should contain a locale as well.
Upon receiving the request, the server does not necessarily have a response that match exactly the incoming locale, thus quite often, it needs to fall back to a most available locale which can best match the incoming locale. For example, in Canada, if a incoming locale is fr-CA, basically Canadian French, but the server does not contain any French data, it might fall back to en-CA, use Canadian English to supply the response.
4. The date time format needs to be standardized.
There are two choices of handling date time format. I) use the same date time format across different locale, this choice is typical for values that is supposed to be read and used by machine, such as the time stamp of a record. II) use a locale specific date time according to the locale of the incoming request, this design choice is typical for those value that needs to be read by human such as strings show up on the UI.
B. How to globalize them?
For web service, the locale fall back logic typically needs to be encoded in the request processing part of the web service. The data for each locale need to be stored in a database for management. The tools of loading the data into the database also needs to be globalized to distinguish the source of the data.