如何更换 AXIS “您好,这是 AXIS 服务!”页?

发布于 2024-10-15 20:56:47 字数 362 浏览 4 评论 0原文

当我访问“http://192.168.0.149:8080/axis/services/MyService”时,我收到此页面

“您好,这是一项 AXIS 服务!

这里可能会有一个用于调用该服务的表单...

我知道这意味着我的 Web 服务工作正常(事实上,我有一个 Java 客户端可以很好地调用它)。但昨天有人问我一个简单的问题,但我不知道答案,也找不到答案。 我们可以用实际的表单替换该页面吗?是否有一个设置可以添加到我们的 web.xml 文件中,或者其他什么?

我知道 axis 在我的服务器上部署为 jar 文件(没有 /axis 目录),所以这可能会限制我的可能性......

When I go to "http://192.168.0.149:8080/axis/services/MyService", I get this page

"Hi there, this is an AXIS service!

Perhaps there will be a form for invoking the service here..."

I know this means my web service is working correctly (in fact, I have a java client that calls it just fine). But yesterday I've been asked a simple question, yet I don't know the answer and couldn't find it. Can we replace that page, by an actual form let's say? Is there a setting to add to our web.xml file, or perhaps something else?

I know that axis is deployed as a jar file on my server (there's no /axis directory), so this may limit my possibilities...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云淡风轻 2024-10-22 20:56:47

找到了解决方案。

您可以子类化 AxisServlet 并重新定义 reportServiceInfo() 方法(即打印“嗨,...”的方法)。

package com.abcd.ws;

import java.io.IOException;

@SuppressWarnings("serial")
public class MyAxisServlet extends org.apache.axis.transport.http.AxisServlet {
    protected void reportServiceInfo(
            javax.servlet.http.HttpServletResponse response,
            java.io.PrintWriter writer, org.apache.axis.handlers.soap.SOAPService service,
            java.lang.String serviceName) {
        //writer.write("We can print stuff here, or redirect :");
        // The leading slash means we are redirecting using an absolute path
        String redirectPage = response.encodeRedirectURL("/" + serviceName + ".jsp");
        try {
            response.sendRedirect(redirectPage);
        } catch (IOException e) {
            e.printStackTrace();
        }           
    }
}

然后,您需要在 web.xml 中更改 AxisServlet 上的映射以使用该类。

Found a solution.

You can subclass AxisServlet and redefine the reportServiceInfo() method (that's the one that prints "Hi there, ...").

package com.abcd.ws;

import java.io.IOException;

@SuppressWarnings("serial")
public class MyAxisServlet extends org.apache.axis.transport.http.AxisServlet {
    protected void reportServiceInfo(
            javax.servlet.http.HttpServletResponse response,
            java.io.PrintWriter writer, org.apache.axis.handlers.soap.SOAPService service,
            java.lang.String serviceName) {
        //writer.write("We can print stuff here, or redirect :");
        // The leading slash means we are redirecting using an absolute path
        String redirectPage = response.encodeRedirectURL("/" + serviceName + ".jsp");
        try {
            response.sendRedirect(redirectPage);
        } catch (IOException e) {
            e.printStackTrace();
        }           
    }
}

You then need to change in your web.xml the mapping on AxisServlet to use that class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文