Web services Apache CXF服务列表页面的定制

Web services Apache CXF服务列表页面的定制,web-services,cxf,javadoc,Web Services,Cxf,Javadoc,我有一个由ApacheCXF生成的网页,它用方法显示了我的应用程序中所有可用的soap Web服务。我还为我的Web服务生成了一些Javadoc。我想定制ApacheCXF生成的Web服务列表,Web服务的名称是指向javadoc的链接,方法名称也是如此。可能吗?我不想更改ApacheCXF库的代码。我使用的是CXF版本2.3.7。您可以发现serviceList是从ServiceListGeneratorServlet生成的。 但是我认为您需要创建一个新的CXFNonSpringServlet

我有一个由ApacheCXF生成的网页,它用方法显示了我的应用程序中所有可用的soap Web服务。我还为我的Web服务生成了一些Javadoc。我想定制ApacheCXF生成的Web服务列表,Web服务的名称是指向javadoc的链接,方法名称也是如此。可能吗?我不想更改ApacheCXF库的代码。我使用的是CXF版本2.3.7。

您可以发现serviceList是从ServiceListGeneratorServlet生成的。
但是我认为您需要创建一个新的CXFNonSpringServlet来替换保存ServiceListGeneratorServlet的ServletController。

您可以使用Servlet过滤器覆盖Servlet返回的响应。这不是最有效的解决方案,但您不需要对任何CXF类进行子类化

其思想是将
HttpServletResponseWrapper
的自定义实例传递给
FilterChain.doFilter
方法。包装器防止servlet响应(即服务列表页面)直接写入ouptut。因此,稍后可以在过滤器中检索响应,并在发送到客户端之前进行修改

以下示例的灵感来自

最后,在web.xml中注册过滤器,如下所示。您需要调整url模式以点击服务列表页面

<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <filter>
        <filter-name>DocumentationFilter</filter-name>
        <filter-class>org.mypackage.DocumentationFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>DocumentationFilter</filter-name>
        <url-pattern>/</url-pattern> <!-- The location of the service list page -->
    </filter-mapping>
...
</web-app>

文档过滤器
org.mypackage.DocumentationFilter
文档过滤器
/ 
...
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <filter>
        <filter-name>DocumentationFilter</filter-name>
        <filter-class>org.mypackage.DocumentationFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>DocumentationFilter</filter-name>
        <url-pattern>/</url-pattern> <!-- The location of the service list page -->
    </filter-mapping>
...
</web-app>