user2722197
user2722197

Reputation: 51

Disable auto generated JAX-WS Status Page

When I deploy and run my web service developed with JAX-WS I can see a summary page with some info on it, something like in this picture:

http://www.mkyong.com/webservices/jax-ws/deploy-jax-ws-web-services-on-tomcat/ Web service status page

For the final implementation we would like to remove this page so that a custom or a blank page is returned while still having access to the web service endpoint.

We are currently running on Tomcat.

Upvotes: 5

Views: 1671

Answers (3)

goodnewspostman
goodnewspostman

Reputation: 1

I have completed the same task for WebLogic recently. It was requested to hide/show a status page of a public web service depending on a target environment i.e. hide for production, show for dev. Nothing of the previous answers worked for me. The success solution is based on implementation of javax.servlet.Filter.

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.HttpMethod;


@WebFilter(urlPatterns = { "/WeblogicWebService" })
public class FilterStatusSoapPage implements Filter {

     @Value("${soap.status.page.disabled}")
     private boolean flagDisablePublishStatusPage;

     public void doFilter(
            ServletRequest request, 
            ServletResponse response, 
            FilterChain chain) throws IOException, ServletException {
        try {
            HttpServletRequest httpReq = (HttpServletRequest) request;
            HttpServletResponse httpRes = (HttpServletResponse) response;
            String queryString = httpReq.getQueryString();
            if(flagDisablePublishStatusPage)
             if(queryString == null || queryString.trim().isEmpty())
                if(HttpMethod.GET.matches(httpReq.getMethod())) {
                    httpRes.setStatus(HttpServletResponse.SC_OK);
                    httpRes.getWriter().write("Access to status page of Web 
                                        Service is not allowed");
                    httpRes.getWriter().flush();
                    httpRes.getWriter().close();
                    return; 
                } 

        } catch (Exception e) {
            System.err.println("Error on FilterStatusSoapPage filter");
            chain.doFilter(request, response);
            return;
        }
        chain.doFilter(request, response);
    }
    public void init(FilterConfig fConfig) throws ServletException {}
    public void destroy() {}
} 

Upvotes: 0

balayyoub
balayyoub

Reputation: 13

I have been trying to solve this for two days, Glassfish 3.1.2.
The only solution was to have
-Dcom.sun.xml.ws.transport.http.HttpAdapter.publishStatusPage=false
I know its old, but wantd to maintain the knowledge. Hope this helps any one with this issue.

Upvotes: 0

Bogdan
Bogdan

Reputation: 24590

There is a field on the WSServlet class that might do what you are looking for: JAXWS_RI_PROPERTY_PUBLISH_STATUS_PAGE (it's value is com.sun.xml.ws.server.http.publishStatusPage).

Looking at the source code from a JAX-WS download it seems that you need to set it as a context parameter in your web.xml file:

<web-app>
  <context-param>
     <param-name>com.sun.xml.ws.server.http.publishStatusPage</param-name>
     <param-value>false</param-value>
  </context-param>
  ...

Seems that HttpAdapter had something similar on it but was taken from an environment variable:

setPublishStatus(
    System.getProperty(HttpAdapter.class.getName() + ".publishStatusPage")
    .equals("true"));

The code on HttpAdapter is marked deprecated in the javadoc so the context parameter seems the way to go.

Upvotes: 4

Related Questions