我创建了一个新的Web服务模块,以在Java版本1.6的JBoss 4上进行部署。
部署WAR时,我看到以下内容:
[2020-09-16 13:52:15,291] INFO TomcatDeployer - deploy, ctxPath=/mywebservice, warUrl=.../tmp/deploy/tmp2845842491421857926mywebservice-exp.war/
[2020-09-16 13:52:15,766] ERROR STDERR - Sep 16, 2020 1:52:15 PM com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
INFO: WSSERVLET12: JAX-WS context listener initializing
[2020-09-16 13:52:18,552] ERROR STDERR - Sep 16, 2020 1:52:18 PM com.sun.xml.ws.transport.http.servlet.WSServletDelegate <init>
INFO: WSSERVLET14: JAX-WS servlet initializing
从我的在线阅读中,我应该能够看到该服务在这里运行:
http://localhost:8080/mywebservice
mywebservice 是此处的WAR文件的名称。
所以我也尝试了以下两种方法,但返回的结果相同。
http://localhost:8080/mywebservice/MYS
http://localhost:8080/mywebservice/MYS?wsdl
这是我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<description>My Web Services endpoint</description>
<display-name>MYSServlet</display-name>
<servlet-name>MYSServlet</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>MYSSServlet</servlet-name>
<url-pattern>/services/mys/*</url-pattern>
</servlet-mapping>
</web-app>
这是我的sun-jaxws.xml:
<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>
<endpoint
name='MYS'
implementation='com.dep.service.MYS'
url-pattern='/services/MYS'/>
</endpoints>
MYS java类具有以下内容:
@WebMethod
public String sayHelloWorldFrom(String from) {
String result = "Hello world, from " + from;
System.out.println(result);
return result;
}
我对此很陌生,所以有人可以在这里指导我正确的方向吗?或者我在这里做错了什么?