Java 在 Tomcat 上访问 wsdl
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2396468/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
accessing wsdl on Tomcat
提问by Krt_Malta
I have a web service and I was deploying it on GlassFish. I accessed its wsdl through http://localhost:10697/APIService/APIServiceService?wsdl.
我有一个 Web 服务,我将它部署在 GlassFish 上。我通过http://localhost:10697/APIService/APIServiceService?wsdl访问了它的wsdl。
Now I ported the WAR file to a Tomcat 6.0.24 and it is deployed. However I am trying to access its wsdl using http://localhost:8080/APIService/APIServiceService?wsdlbut I'm getting a 404 error. I tried various combinations but none seem to work.
现在我将 WAR 文件移植到 Tomcat 6.0.24 并部署它。但是,我正在尝试使用http://localhost:8080/APIService/APIServiceService?wsdl访问其wsdl,但出现 404 错误。我尝试了各种组合,但似乎都不起作用。
How can I access the wsdl file plz?
请问如何访问wsdl文件?
Thanks and regards,
感谢致敬,
Update:Here you are: web.xml
:
更新:你在这里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>
I can't find sun-jaxws.xml
however... Thanks a lot! Regards
sun-jaxws.xml
但是我找不到...非常感谢!问候
采纳答案by Pascal Thivent
The way to access a WSDL is not really container specific, it's more WS-stack specific. The WS-stack in GlassFish is Metro (Metro = JAX-WS RI + WSIT). Did you install/deploy Metro or JAX-WS RI on Tomcat? See Metro on Tomcat 6.xor Running JAX-WS Samples with Tomcat 6.x(JAX-WS RI might be enough in your case) for the steps.
访问 WSDL 的方式实际上并不是特定于容器的,而是更特定于 WS 堆栈的。GlassFish 中的 WS 堆栈是 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 可能就足够了)。
Update:You need to declare the WSServlet
in the web.xml
(see Deploying Metro endpoint):
更新:您需要WSServlet
在web.xml
(请参阅部署 Metro 端点)中声明:
<?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>
And then in the sun-jaxws.xml
(also packaged in WEB-INF), declare your Service Endpoint Interface (SEI):
然后在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>
And you access the WSDL at:
您可以在以下位置访问 WSDL:
http://localhost:8080/<mycontext>/services/hello?wsdl
A B C D
- A is the host and port of the servlet container.
- B is the name of the war file.
- C comes from the url-pattern element in the web.xml file.
- D comes from the ending stem of the url-pattern attribute in the sun-jaxws.xml file.
- A 是 servlet 容器的主机和端口。
- B 是war 文件的名称。
- C 来自 web.xml 文件中的 url-pattern 元素。
- D 来自 sun-jaxws.xml 文件中 url-pattern 属性的结尾词干。