views:

182

answers:

2

I'm developing a web service that needs to return results in both french and english. (Other languages may be added later.) The web service is written in C#.

I have separated all of the strings into a resource file. I was planning on adding a parameter to the service and setting the Thread.CurrentThread.CurrentCulture to the appropriate value. Then when I go to retrieve the correct string I check the CurrentCulture value.

Is this a good practice?

+2  A: 

Rather than adding a parameter to every call in the service (or to whatever sort of webservice context you've got - it's a while since I've done any WS stuff), have you thought of hosting the web service under different URLs to represent the different languages?

I'm not going to claim it's a fabulous idea, but it has the benefit of being really simple :) Seriously, I'm sure there will be lots of pros and cons, but it's another thing to throw into the mix.

Jon Skeet
I like the simplicity of using different URL's and not having to pass an additional parm, but I would like to avoid the extra deployment and configuration overhead with multiple URL's.
scurial
+2  A: 

This type of information goes into the soap headers. Check this link for information on how to set it up: http://geekswithblogs.net/claeyskurt/archive/2007/10/23/SoapHeadersInWCFforAMSXClients.aspx.

eglasius