没有sun-jaxws.xml的Tomcat上的JAX-WS Web服务 [英] JAX-WS Web service on Tomcat without sun-jaxws.xml

查看:477
本文介绍了没有sun-jaxws.xml的Tomcat上的JAX-WS Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Tomcat上部署基于JAX-WS的Web服务时最小化所需的配置。随着Servlet 3.0的引入(由Tomcat 7+支持), web.xml 可以被抛出,但仍然有 sun-jaxws.xml 。这个博文很有意思:

I am trying to minimize required configuration while deploying JAX-WS-based Web service on Tomcat. With the introduction of Servlet 3.0 (supported by Tomcat 7+), web.xml can be thrown out, but there is still sun-jaxws.xml. This blog post is interesting:


当然,使用jax-ws注释,即使配置
sun-jaxws.xml也可以是可选的使它完全描述符
免费,但这需要指定一个默认的url模式,如
JSR-109或自定义模式,如Jersey REST服务,在JAX-WS
规范中。

Of course, with the use of jax-ws annotations, even configuration sun-jaxws.xml can be made optional making it completely descriptor free, but that requires specifying a default url-pattern like in JSR-109 or custom pattern like in Jersey REST services, in the JAX-WS specification.

是否可以在Tomcat上避免 sun-jaxws.xml ,以及如何?

Is it possible to avoid sun-jaxws.xml on Tomcat, and how?

推荐答案

可悲的是,配置必须存在某处。根据消息来源,这是强制性的。信不信由你, sun-jaxws.xml文件的位置是硬编码的到/WEB-INF/sun-jaxws.xml(谢谢,伙计们@Metro)。

Sadly, the configuration must exist somewhere. That is mandatory, per the source. Believe it or not, the location of the sun-jaxws.xml file is hard-coded to /WEB-INF/sun-jaxws.xml (thanks, guys @ Metro).

实际上,您需要控制以下类别

公共类WSServlet

需要做什么:


  1. WSServletContextListener 显然不会被扩展。此侦听器根据sun-jaxws.xml和jaxws-catalog文件执行大多数初始化。就像我之前提到的,位置是硬编码的。所以你在这里阻力最小的路径是

  1. WSServletContextListener will obviously not be extended. This listener performs most of the initializations per the sun-jaxws.xml and jaxws-catalog file. Like I mentioned earlier, the location is hard coded. So your path of least resistance here is to


  • 实现你自己的vanilla servlet监听器(带有 @WebListener )并调用新的WSServletContextListener()。然后,您将自己的 contextInitialized(ServletContext ctxt) contextDestroyed()方法委派给您的实例中的方法 WSServletContextListener

  • implement your own vanilla servlet listener (with @WebListener) and call a new WSServletContextListener(). You'll then delegate your own contextInitialized(ServletContext ctxt) and contextDestroyed() methods to the ones in your instance of WSServletContextListener.

使用 @XmlRootElement 类,即时生成监听器实例化的文件'll代表sun-jaxws文件(我会在短时间内提供一个这样的样本,现在没有时间:))。

Generate the file on instantiation of the listener, on the fly, using an @XmlRootElement class that'll represent the sun-jaxws file(I'll provide a sample of this in a short while, don't have the time right now :) ).

对于这样一个可有可无的便利,IMO来说很麻烦,但它应该在理论上起作用。我会写一些样本,看看他们很快就会播放。

It's a lot of trouble for such a dispensable convenience, IMO, but it should work in theory. I'll write some samples and see how they play shortly.

这篇关于没有sun-jaxws.xml的Tomcat上的JAX-WS Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆