如何在 OSGi 容器中使用 JAX-WS 通过 HTTPS 发布 Web 服务?
使用 Java,可以轻松地通过 HTTPS 使用 Web 服务,但如何发布 Web 服务呢?
标准 JAX-WS 实现不支持它。我们尝试了 Jetty,但 Jetty 也不支持 HTTPS 上的 Web 服务(JettyHttpServerProvider
的 createHttpsServer()
抛出 UnsupportedOperatonException
)。我想这个问题应该很简单。但不知何故,我总是碰壁。
此外,这必须与 OSGi 一起使用,因此我希望大多数或所有依赖项都可以作为捆绑包提供。目前,我尝试运行 CXF,但它有很多非 OSGi 依赖项,这使得部署非常困难。
我们还需要通过证书进行客户端身份验证,但我希望一旦启用 HTTPS,这将相对容易。
为什么这有这么大的事?例如,要使用 Jetty 提供静态内容,您所需要做的就是创建一个服务器,添加任何 SSL 连接器,然后就完成了。为什么 Web 服务就不能那么容易呢?
With Java it is easy to consume a Web Service over HTTPS but how do you publish one?
The standard JAX-WS implementation doesn't support it. We tried Jetty but Jetty does not have support for Web Services over HTTPS either (JettyHttpServerProvider
's createHttpsServer()
throws an UnsupportedOperatonException
). I think this problem should be really easy. But somehow I always run against walls.
Additionally this has to work with OSGi so I'd prefer if most or all dependencies are available as bundles. Currently I try to get CXF running but it has a lot of non-OSGi dependencies which makes deployment very hard.
We also need client authentication via certificates but my hope is this will be relatively easy once HTTPS is enabled.
Why is this such a big deal? For example to provide static content with Jetty, all you need to do is create a server, add any SSL connector and you're done. Why can't it be that easy for Web Services?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们的系统在OSGi中使用cxf和jetty,并且它与HTTPS一起工作得很好。
当您将服务发布到 WebService 时,您不应该关心它是 HTTP 还是 HTTPS。通过将以下属性传递给 OSGi,将您的 jetty 配置为支持 HTTPS:
您可以在中查看其他属性
通过执行此操作,您可以尝试使用 IE 通过 https 访问您的服务的 wsdl。
Our system uses cxf and jetty in OSGi, and it works fine with HTTPS.
When you publish your service to WebService, you should not concern it is HTTP or HTTPS. Configure your jetty to support HTTPS by passing the following properties to OSGi:
You can check out the other properties in
By doing this, you can try to use IE to access the wsdl of your service through https.
如果您使用的是spring,则可以使用以下配置。这篇关于 FuseSource 的文章很好地解释了配置所需的步骤。
If you are using spring, you could use the following configuration. This article on FuseSource gives a good explanation of steps needed for configuration.