I am developing a SOAP web service in Java using metro.
I want to deliver the response in in the client language.
My idea is to return all the string fields translates. This is not the main purpose for the web service, but is a needed convenience.
The ResourceBundle is a java class that handles the loading of the correct set of strings according the client Location.
Is this class the best approacher?
And the real question: in a WS environment how to know the client location?
EDIT:
I like @Volker idea, let decide what language will be used.
How to send the intentions to the service?
- Header parameter?
- Method (body) parameter?
- Any other option?
Generally, I would say, if possible, let the client explicitly tell you what language he wants and deliver it according to his needs.
This may be an additional web method “getSupportedLanguages” which delivers a list of enUS, deDE or whatever and your other methods may accept those languages and deliver the correct response. Or deliver all language versions and let the client sort it out. But this may be a bit network overkill depending on the number of supported locales…
In my opinion, WebServices should “stand on their own”, the clients should be thin and not require lots of information to process the content. Imagine a C#-client, who may not be able to work with your Ressources or whatever. Or a new client without ressources not being able to work with your data…
Additionally, it could be different to really get the clients locale – a non-english person may use an english system or may be in an english country, but would like to see data in his native language. But if you really need to do this, I’m not aware of anything to enable this.