can we override Apache CXF generated HTML page
i tried
<init-param> <param-name>hide-service-list-page</param-name> <param-value>true</param-value> </init-param>
but it shows "No service was found" instead of showing this how can we show different html page. Thanks
1 Answers
Answers 1
Apache cxf use a class called FormattedServiceListWriter
to generate the html page that you are talking about, you can take a look of the code here.
What you can do to personalize that page is to create a class in your project with the exact same name in the same package org.apache.cxf.transport.servlet.servicelist
(you have to create that package in your project also), and change the writeServiceList
method for your own implementation, that class will have priority over the one in the cxf jar
new FormattedServiceListWriter
class
package org.apache.cxf.transport.servlet.servicelist; /*--imports--*/ public class FormattedServiceListWriter implements ServiceListWriter { /*... this remains the same as in the original class*/ public void writeServiceList(PrintWriter writer, String basePath, AbstractDestination[] soapDestinations, AbstractDestination[] restDestinations) throws IOException { /*this is the method you should change*/ writer.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" " + "\"http://www.w3.org/TR/html4/loose.dtd\">"); writer.write("<HTML><HEAD>"); writer.write("<LINK type=\"text/css\" rel=\"stylesheet\" href=\"" + styleSheetPath + "\">"); writer.write("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">"); if (title != null) { writer.write("<title>" + title + "</title>"); } else { writer.write("<title>CXF - Service list</title>"); } writer.write("</head><body>"); writer.write("<span class=\"heading\">WHATEVER YOU WANT TO PUT HERE</span>"); writer.write("</body></html>"); } /*... this remains the same as in the original class*/ }
0 comments:
Post a Comment