我正在使用 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/