Tomcat上发布webservices的war工程,访问异常404
Tomcat部署正常、war导出工程正常、Tomcat自带的工程可以正常访问;
问题:
webservices工程访问异常404
解决方案:
因为webservices的wsdl访问设置的端口与tomcat端口冲突;
package nc.xyzq.listener; import java.net.InetAddress; import java.net.UnknownHostException; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import javax.xml.ws.Endpoint; import nc.xyzq.uuib.service.impl.FrServiceImpl; /** * @author gacl * 用于发布WebService的监听器 */ //使用Servlet.提供的@WebListener注解将实现了ServletContextListener接口的WebServicePublishListener类标注为一个Listener @WebListener public class WebServicePublishListener implements ServletContextListener { @Override public void contextDestroyed(ServletContextEvent sce) { System.gc(); } @Override public void contextInitialized(ServletContextEvent sce) { //WebService的发布地址 String ip =""; try { ip = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("本机的IP = " + ip); String address = "http://"+ip+":8080/webservices/WebService"; //发布WebService,WebServiceImpl类是WebServie接口的具体实现类 Endpoint.publish(address , new FrServiceImpl()); System.out.println("使用WebServicePublishListener发布webservice成功!"); } }
端口8080跟tomcat的端口冲突;将wsdl地址的端口改为8060即可;
时间: 2024-11-07 18:47:01