如何更改jax ws webservice的8080端口?

How to change port from 8080 of jax ws webservice?

我遵循 https://www.mkyong.com/webservices/jax-ws/deploy-jax-ws-web-services-on-tomcat/ 本教程并在端口 8080 上创建了一个网络服务 运行。

我看到了这个选项:

jax-ws webservice's endpoint is always localhost

但我想知道是否有其他方法可以在可配置文件中设置端口?

我只有sun-jaxws.xml和web.xml。我还需要 1 个文件吗?

我是这样定义的:

@WebService(endpointInterface="com.abc.service.ClassName",portName = "WebservicePort", 
serviceName = "ABCFunctions")

太阳 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" />

发布网络服务时,您可以更改端口号