如何设置 servlet 的映射,使其在与 CXF 相同的路径上侦听?

How to set the mappings of a servlet so that it listens on the same path as CXF?

来自我的 pom 的依赖项:

2.2.5.RELEASE 对于 Spring 3.3.5 为 CXF

以下是 application.yml 中定义的服务器设置:

server:
 port: 8080
 servlet:
  context-path: /cs

第一个 Servlet 是 CXF JAXWS 端点,配置如下:

// https://github.com/apache/cxf

@Bean(name=Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {
    return new SpringBus();
}

@Bean
public IFileNetWSSoap documentService() {
    return new DocumentServiceEndpoint();
}

@Bean
public Endpoint endpoint() {
    EndpointImpl endpoint = new EndpointImpl(springBus(), documentService());
    endpoint.setServiceName(fileNetWS().getServiceName());
    endpoint.setWsdlLocation(fileNetWS().getWSDLDocumentLocation().toString());
    endpoint.publish(properties.getDocumentEndpoint());
    Binding binding = endpoint.getBinding();
    ((SOAPBinding)binding).setMTOMEnabled(true);
    return endpoint;
}

目前正在这个地址收听:http://localhost:8080/cs/services/document-service_1.0

第二个 Servlet 是 javax.servlet.http.HttpServlet(现在是 TomCat):

    @WebServlet(urlPatterns = {"/image-service_1.0"})
    public class ImageServiceEndpoint extends HttpServlet {

    @Autowired
    private BusinessService businessServices;

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) {
        doGet(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) {
        this.businessServices.imageRetrieval(request, response);
    }
}

目前正在这个地址收听:http://localhost:8080/cs/image-service_1.0

最后,还有 Spring-Boot Actuator Servlet。

目前正在这个地址收听:http://localhost:8080/cs/actuator

我的问题是"How can I configure the WebServlet to listen on the CXF segment without breaking everything?" http://localhost:8080/cs/services/image-service_1.0

我注意到也许我应该使用 Spring MVC 控制器代替 Servlet。我对此端点 ID 的唯一要求是接收查询字符串参数并将二进制内容流式传输回调用方。

您不能接管与 CXF WS Endpoint 相同的路径(默认:/services)