[英]Multiple Languages for WCF Web Services. What are the best practices?
I'm developing a web service that needs to return results in both french and english.我正在开发一个需要以法语和英语返回结果的 web 服务。 (Other languages may be added later.) The web service is written in C#.
(以后可能会添加其他语言。) web 服务是用 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.
我正计划向服务添加一个参数并将 Thread.CurrentThread.CurrentCulture 设置为适当的值。 Then when I go to retrieve the correct string I check the CurrentCulture value.
然后,当我 go 检索正确的字符串时,我检查了 CurrentCulture 值。
Is this a good practice?这是一个好习惯吗?
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?与其向服务中的每个调用(或任何类型的 web 服务上下文添加参数 - 我已经有一段时间没有做过任何 WS 的东西),而是考虑在不同的 URL 下托管 web 服务来表示不同的语言?
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.我不会声称这是一个绝妙的主意,但它的好处是非常简单:) 说真的,我敢肯定会有很多优点和缺点,但这是另一回事。
This type of information goes into the soap headers.此类信息进入 soap 标头。 Check this link for information on how to set it up: http://geekswithblogs.net/claeyskurt/archive/2007/10/23/SoapHeadersInWCFforAMSXClients.aspx .
查看此链接以获取有关如何设置的信息: http://geekswithblogs.net/claeyskurt/archive/2007/10/23/SoapHeadersInWCFforAMSXClients.aspx 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.