JAX-WS Web service on Tomcat without sun-jaxws.xml

前端 未结 4 2109
礼貌的吻别
礼貌的吻别 2021-02-13 12:02

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

4条回答
  •  面向向阳花
    2021-02-13 12:51

    You have to publish the web service. You can implement a ServletContextListener and publish the endpoint:

    @javax.servlet.annotation.WebListener 
    public class AppServletContextListener implements javax.servlet.ServletContextListener {
    
        public void contextInitialized(ServletContextEvent sce) { 
            Endpoint.publish("{protocol}://{host}:{port}/{context}/{wsName}", new MyHelloWorldWSImpl());
        } 
    
        public void contextDestroyed(ServletContextEvent sce) { 
            .... 
        }
    }
    

    sun-jaxws.xml is not mandatory by specs...If you note, for example, glassfish (metro) makes it optional. Also, if you expose a EJB 3.1 as webservice (with jaxws) you can see no sun-jaxws.xml file in the generated build.

提交回复
热议问题