如何指定 jax-ws 服务返回结果应使用的语言?

发布于 2024-12-26 10:32:59 字数 583 浏览 2 评论 0原文

我目前正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧情勿念 2025-01-02 10:32:59

正如另一个答案中所述,您可以使用标准 WS-I18N SOAP 扩展

需要发送国际首选项的 SOAP 文档应该
在标头中包含 i18n:international 元素信息项。
当从请求者发送到提供者时,标头代表
请求者或其客户端应用程序的偏好。当发送时
来自提供商的响应消息,标头代表设置
该服务用于处理请求。

在此博客文章中检查如何在 JAX-WS/Metro 中添加 SOAP 标头(它有具体步骤详细信息的链接)。

希望这有帮助。

As also noted in another answer you can make use of standard WS-I18N SOAP extension.

SOAP documents that need to send international preferences SHOULD
include the i18n:international element information item in a header.
When sent from the requester to a provider, the header represents the
preferences of the requester or its client application. When sent in a
response message from the provider, the header represents the settings
that the service used to process the request.

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.

旧时光的容颜 2025-01-02 10:32:59

这并不奇怪,但有一个标准。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文