JAX-WS 通过 WS-Security 和 WS-Addressing 使用 Web 服务
我正在尝试使用 JAX-WS (Metro) 开发一个独立的 Java Web 服务客户端,该客户端使用 WS-Security 和用户名令牌身份验证(密码摘要、随机数和时间戳)和时间戳验证以及基于 SSL 的 WS-Addressing。
我必须使用的 WSDL 没有定义任何安全策略信息。 当 WSDL 不包含此信息时,我一直无法准确地弄清楚如何添加此标头信息(正确的方法)。 我发现的大多数使用 Metro 的示例都围绕使用 Netbeans 从 WSDL 自动生成它,这对我没有任何帮助。 我研究过 WSIT、XWSS 等,但没有太多清晰度或方向。 JBoss WS Metro 看起来也没什么运气。
有人有这样做的经验或对如何完成这项任务有建议吗? 即使为我指明正确的方向也会有所帮助。 除了必须基于 Java 之外,我不限于特定技术。
I'm trying to develop a standalone Java web service client with JAX-WS (Metro) that uses WS-Security with Username Token Authentication (Password digest, nonces and timestamp) and timestamp verification along with WS-Addressing over SSL.
The WSDL I have to work with does not define any security policy information. I have been unable to figure out exactly how to add this header information (the correct way to do so) when the WSDL does not contain this information. Most examples I have found using Metro revolve around using Netbeans to automatically generate this from the WSDL which does not help me at all. I have looked into WSIT, XWSS, etc. without much clarity or direction. JBoss WS Metro looked promising not much luck yet there either.
Anyone have experience doing this or have suggestions on how to accomplish this task? Even pointing me in the right direction would be helpful. I am not restricted to a specific technology other than it must be Java based.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我最终确实解决了这个问题,但我走了另一个方向。 我的解决方案是使用 CXF 2.1 及其 JAX-WS 实现,将 CXF 的强大功能与我已有的现有 Spring 基础设施相结合。 一开始我很怀疑,因为 CXF 需要大量的 jar,但最终它提供了最好、最简单的解决方案。
改编 CXF 网站进行客户端配置的示例,我使用了Spring 中的自定义 CXF JAXWS 命名空间,并使用 Out Interceptor 进行用户名令牌身份验证(密码摘要、随机数和时间戳)和时间戳验证。 完成这项工作的唯一其他步骤是创建我自己的密码回调处理程序,该处理程序针对每个出站 SOAP 请求执行。
对于 SSL 配置,我再次转向 CXF 及其 SSL通过管道支持,尽管我永远无法使 SSL 与特定的 http:conduit 名称一起工作,但我必须使用不建议用于生产环境的通用名称。
下面是我的配置文件的示例。
Spring 配置文件
Java 客户端密码处理程序:
I did end up figuring this issue out but I went in another direction to do so. My solution was to use CXF 2.1 and its JAX-WS implementation, combining the power of CXF with the existing Spring infrastructure I already had in place. I was skeptical at first because of the numerous jars required by CXF, but in the end it provided the best and simplest solution.
Adapting an example from the CXF website for client configuration, I used the custom CXF JAXWS namespace within spring and used an Out Interceptor for Username Token Authentication (Password digest, nonces and timestamp) and timestamp verification. The only other step to make this work was creating my own Password Callback handler that is executed for each outbound SOAP request.
For SSL configuration, I again turned to CXF and its SSL support via conduits, although I could never make SSL work with a specific http:conduit name, I had to use the general purpose one that is not recommended for production environments.
Below is an example of my config file.
Spring config file
Java Client Password Handler:
如果信息不在 WSDL 中,您确定它在 WSDL 描述的服务中吗? WSDL 旨在提供描述服务所需的所有信息,包括使用服务所需的安全策略。
WSDL 来自哪个平台? WSDL 是否有可能不是完整的描述? 例如,它可能是一个包含在另一个确实提供安全信息的 WSDL 中的 WSDL。
If the information isn't in the WSDL, are you sure it's in the service described by the WSDL? The WSDL is meant to provide all the information necessary to describe the service, including the security policies necessary to use the service.
What platform did the WSDL come from? Is it possible that the WSDL is not the complete description? For instance, it might be a WSDL that is included in another WSDL that does provide the security information.
这里有一篇文章解释了如何使用 WS-Security 在 CXF 中配置客户端和服务器: 使用 Spring 和 CXF 的 JAX-WS Web 服务
There is a post here explaining how to configure a Client and a Server in CXF with WS-Security: JAX-WS Web Services with Spring and CXF