我关注了https://www.mkyong.com/webservices/jax-ws/deploy-jax-ws-web-services-on-tomcat/本教程并制作了一个在端口 8080 上运行的 Web 服务。
我看到了这个选项:
jax-ws webservice's endpoint is always localhost
但我想知道是否有其他方法可以在可配置文件中设置端口?
我只有 sun-jaxws.xml 和 web.xml。我还需要 1 个文件吗?
我这样定义它:
@WebService(endpointInterface="com.abc.service.ClassName",portName = "WebservicePort",
serviceName = "ABCFunctions")
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="ABCFunctions"
implementation="com.abc.service.ClassName""
url-pattern="/ABCFunctions"/>
</endpoints>
web.xml 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems,
Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
<web-app>
<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>ABCFunctions</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>ABCFunctions</servlet-name>
<url-pattern>/ABCFunctions</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>120</session-timeout>
</session-config>
</web-app>
到目前为止,我只能通过 Tomcat 的 server.xml 连接器配置来更改它。 有没有办法让网络服务有一个单独的端口??
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
最佳答案
在发布 web 服务时,您可以更改端口号
关于java - 如何更改jax ws webservice的8080端口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46901631/