如何指定 jax-ws 服务返回结果应使用的语言?
我目前正在开发一个 jax-ws Web 服务,该服务应该提供来自数据库的国际化搜索结果。
我在互联网上查找了一个具体的代码示例,其中 languageCode/languageId 以标准方式与 SOAP 信封一起发送(以避免将 languageId 作为 webservice 方法的参数发送),但还没有到目前为止还没有发现任何具体的东西。
谁能推荐我一个解决这个问题的好方法?
与此同时,我找到了一种通过 HTTP 请求标头传输元数据(语言 ID、用户、密码)的方法 javax.xml.ws.handler.MessageContext.HTTP_REQUEST_HEADERS
http ://www.mkyong.com/webservices/jax-ws/application-authentication-with-jax-ws/
有没有人看到一些明显的缺点使用这样的传输方法(通过 HTTP 标头而不是在 SOAP 信封中)?
I am currently working on a jax-ws webservice which is suppossed to provide internationalised search results from a database.
I've looked over the internet for finding a concrete sample of code where the languageCode/languageId is sent in a standard manner along with the SOAP envelope (in order to avoid sending the languageId as a parameter of the webservice method), but haven't found anything concrete so far.
Can anyone recommend me a good approach on how to tackle this problem?
In the meantime i've found a manner to transport the metadata (languageId, user, password) over HTTP Request Headers
javax.xml.ws.handler.MessageContext.HTTP_REQUEST_HEADERS
http://www.mkyong.com/webservices/jax-ws/application-authentication-with-jax-ws/
Does anybody see some clear drawbacks in making use of such a transport method (over HTTP headers and not in the SOAP envelope)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如另一个答案中所述,您可以使用标准 WS-I18N SOAP 扩展。
在此博客文章中检查如何在 JAX-WS/Metro 中添加 SOAP 标头(它有具体步骤详细信息的链接)。
希望这有帮助。
As also noted in another answer you can make use of standard WS-I18N SOAP extension.
Check how you can add SOAP headers in JAX-WS/Metro in this blog post (it has links to specific steps details).
Hope this helps.
这并不奇怪,但有一个标准。 http://www.w3.org/TR/ws-i18n/
但是我我不确定它的可行性如何。
Not very surprisingly, but there is a standard for it. http://www.w3.org/TR/ws-i18n/
However I am not sure how viable it is.