Disable JAX-WS auto-generated status page

When I deploy and run my web service developed using JAX-WS, I see a summary page with some information about this, something like this image:

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 delete this page in order to return a user or blank page, while still having access to the web service endpoint.

We are currently working on Tomcat.

+4
source share
3 answers

The WSServlet class has a field that can do what you are looking for: JAXWS_RI_PROPERTY_PUBLISH_STATUS_PAGE (this is the value com.sun.xml.ws.server.http.publishStatusPage ).

If you look at the source code from the JAX-WS download, you need to set it as a context parameter in the web.xml :

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

It seems that the HttpAdapter has something similar to it, but was taken from an environment variable:

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

The code in the HttpAdapter marked as deprecated in javadoc, so the context parameter seems capable.

+3
source

I tried to solve this problem in two days, Glassfish 3.1.2.
The only solution was to have
-Dcom.sun.xml.ws.transport.http.HttpAdapter.publishStatusPage=false
I know his old, but I wanted to keep knowledge. Hope this helps anyone with this problem.

0
source

I recently completed the same task for WebLogic. It was suggested to hide / show the status page of the public web service depending on the target environment, i.e. hide for production, show to developer. None of the previous answers helped me. A successful solution is based on the 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() {} } 
0
source

Source: https://habr.com/ru/post/1499172/


All Articles