java - 更改 Axis Web 服务 URL

标签 java web-services url webserver axis

我正在使用 Axis 创建 Web 服务,并在运行时使用 AdminClient 在运行时部署我的 Web 服务。运行我的 java 文件后,我可以使用此 URL 访问我的 Web 服务

http://127.0.0.1:8099/axis/services/MyWebService .

我想知道如何在运行时更改使用 axis 部署的 Web 服务的 URL。 我想将该 URL 更改为

http://127.0.0.1:8099/MyWebService (OR) http://127.0.0.1:8099 .

我该怎么做?有什么建议吗?

这是我的代码。

import java.io.FileInputStream;
import java.io.InputStream;
import java.net.ServerSocket;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.axis.transport.http.SimpleAxisServer;

public class AxisTest {

    // start SimpleAxisServer
    public AxisTest(){        
    }
    public static void main(String[] args){
        try {
            int port = 8099;
            SimpleAxisServer server = new SimpleAxisServer();

            System.out.println("Opening server on port: "+ port);

            ServerSocket ss = new ServerSocket(port);
            ss.setSoTimeout(10000);
            server.setServerSocket(ss);

            server.start();
            System.out.println("Starting server...");

            // Read the deployment description of the service

            String deploymenDescriptorFileName = "deploy.wsdd";
            InputStream deploymentDescriptorStream = new     FileInputStream(deploymenDescriptorFileName); 

            // Now deploy our  web service            
            org.apache.axis.client.AdminClient adminClient;

            adminClient = new org.apache.axis.client.AdminClient();

            System.out.println("Deploying receiver server web service...");
            String process = adminClient.process(
                    new org.apache.axis.utils.Options(new String[] {"-ddd","-tlocal"}), 
                    deploymentDescriptorStream);
            System.out.println("Process : "+process);
            System.out.println("Server started. Waiting for connections on: " + port);

        } catch (Exception ex) {
            Logger.getLogger(AxisTest.class.getName()).log(Level.SEVERE, null, ex);
        } 
    }
}

最佳答案

stringy05答案几乎是正确的。是的,你可以找到它here .

要得到你想要的,你应该添加 <parameter name="axis.servicesPath" value="/"/>

正如教程中所说:

Path to the Axis servlet. This should be the same as the services servlet-mapping defined in web.xml. Used for displaying the list of services. Default is "/services/"

您应该修改您的 web.xml如下:

<servlet-mapping>
   <servlet-name>AxisServlet</servlet-name>
   <url-pattern>/*</url-pattern>
</servlet-mapping>

关于java - 更改 Axis Web 服务 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22625629/

相关文章:

java - 如何将多种类型的用户重定向到各自的 Activity?

java - Azure 批量启动任务超出 autoScaleEvaluationInterval

java - JDK8 : "java.lang.NoClassDefFoundError: javax/xml/ws/Service"

java - 在 Restful Web 服务中打开 Tomcat 服务器上的 html 文件

java - RestTemplate.exchange() 不编码 '+' ?

java - 如何查找句子中二元语法的索引

java - 我无法在其中输入高于 9 的值

Java Web 服务,xsd 日期而不是 dateTime

java - H2:JdbcSQLException:URL 格式错误

php - Zend Framework 是否有构建 URL 查询字符串的助手?