我有一个Web服务,我正在GlassFish上部署它.我通过
http://localhost:10697/APIService/APIServiceService?wsdl访问了它的wsdl.
现在我将WAR文件移植到Tomcat 6.0.24中,并将其部署.但是我试图访问其wsdl使用http://localhost:8080/APIService/APIServiceService?wsdl,但我收到404错误.我尝试了各种组合,但似乎没有任何效果.
如何访问wsdl文件plz?
感谢致敬,
更新:这里你是:web.xml:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
我找不到sun-jaxws.xml然而…非常感谢!问候
解决方法
访问WSDL的方式并不是特定于容器的特定的WS-stack. GlassFish中的WS-stack是Metro(Metro = JAX-WS RI WSIT).您是否在Tomcat上安装/部署Metro或JAX-WS RI?有关步骤,请参见
Metro on Tomcat 6.x或
Running JAX-WS Samples with Tomcat 6.x(JAX-WS RI可能足够在您的情况下).
更新:您需要在web.xml中声明WSServlet(参见Deploying Metro endpoint):
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <listener> <listener-class> com.sun.xml.ws.transport.http.servlet.WSServletContextListener </listener-class> </listener> <servlet> <servlet-name>WebServicePort</servlet-name> <servlet-class> com.sun.xml.ws.transport.http.servlet.WSServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>WebServicePort</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> <session-config> <session-timeout>60</session-timeout> </session-config> </web-app>
然后在sun-jaxws.xml(也包装在WEB-INF中),声明您的服务端点接口(SEI):
<?xml version="1.0" encoding="UTF-8"?> <endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0"> <endpoint name="MyHello" implementation="hello.HelloImpl" url-pattern="/hello" /> </endpoints>
并且您访问WSDL:
http://localhost:8080/<mycontext>/services/hello?wsdl A B C D
> A是servlet容器的主机和端口.> B是战争文件的名称.> C来自web.xml文件中的url-pattern元素.> D来自sun-jaxws.xml文件中的url-pattern属性的结尾部分.