PrintWriter writer = response.getWriter();
try
{
AxisEngine engine = getEngine();
ServletContext servletContext =
getServletConfig().getServletContext();
String pathInfo = request.getPathInfo();
String realpath = servletContext.getRealPath(request.getServletPath());
if (realpath == null) {
realpath = request.getServletPath();
}
boolean wsdlRequested = false;
boolean listRequested = false;
boolean hasParameters = request.getParameterNames().hasMoreElements();
//JWS pages are special; they are the servlet path and there
//is no pathinfo...we map the pathinfo to the servlet path to keep
//it happy
boolean isJWSPage = request.getRequestURI().endsWith(".jws");
if(isJWSPage) {
pathInfo= request.getServletPath();
}
// check first if we are doing WSDL or a list operation
String queryString = request.getQueryString();
if (queryString != null) {
if (queryString.equalsIgnoreCase("wsdl")) {
wsdlRequested = true;
} else if (queryString.equalsIgnoreCase("list")) {
listRequested = true;
}
}
boolean hasNoPath = (pathInfo == null || pathInfo.equals(""));
if (!wsdlRequested && !listRequested && hasNoPath) {
// If the user requested the servlet (i.e. /axis/servlet/AxisServlet)
// with no service name, present the user with a list of deployed
// services to be helpful
// Don't do this if we are doing WSDL or list.
reportAvailableServices(response, writer, request);
} else if (realpath != null) {
// We have a pathname, so now we perform WSDL or list operations
// get message context w/ various properties set
MessageContext msgContext = createMessageContext(engine, request, response);
try {
// NOTE: HttpUtils.getRequestURL has been deprecated.
// This line SHOULD be:
// String url = req.getRequestURL().toString()
// HOWEVER!!!! DON'T REPLACE IT! There's a bug in
// req.getRequestURL that is not in HttpUtils.getRequestURL
// req.getRequestURL returns "localhost" in the remote
// scenario rather than the actual host name.
//
// ? Still true? For which JVM's?
String url = HttpUtils.getRequestURL(request).toString();
msgContext.setProperty(MessageContext.TRANS_URL, url);
if (wsdlRequested) {
// Do WSDL generation
processWsdlRequest(msgContext, response, writer);
} else if (listRequested) {
// Do list, if it is enabled
processListRequest(response, writer);
} else if (hasParameters) {
// If we have ?method=x¶m=y in the URL, make a stab
// at invoking the method with the parameters specified
// in the URL
processMethodRequest(msgContext, request, response, writer);
} else {
// See if we can locate the desired service. If we
// can't, return a 404 Not Found. Otherwise, just
// print the placeholder message.
String serviceName;
if (pathInfo.startsWith("/")) {
serviceName = pathInfo.substring(1);
} else {
serviceName = pathInfo;
}
SOAPService s = engine.getService(serviceName);
if (s == null) {
// no such service....
response.setStatus(java.net.HttpURLConnection.HTTP_NOT_FOUND);
response.setContentType("text/html");
writer.println("<h2>" +