How to replace AXIS' "Hi there, this is an AXIS service!" page?
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 per开发者_Python百科haps 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...
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.
精彩评论