Search code examples
cxfspring-integration

Restful API becomes 404 when using the CXF at the same time


I have a project starts up with Spring Boot. It has some restful API via Spring Integration inbound gateway. Afterward, some webservice endpoint added to the project with CXF.

When I setup the CXFServlet mapping, all the restful API became 404.

Only I suspend the CXF config the restful API available again.

May I know if there is anything block the restful API or the spring integration inbound gateway during using CXF?

CXFServlet and Bus

@Configuration
@ComponentScan("com.kennie")
@ImportResource("classpath:cxf-services.xml")
public class SimbaAdapterApplicationConfiguration {

@Bean
public ServletRegistrationBean dispatcherServlet() {
    return new ServletRegistrationBean(new CXFServlet(), "/ws/*");
}

@Bean(name=Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {      
    SpringBus bus = new SpringBus();
    bus.getInInterceptors().add(new LoggingInInterceptor());
    bus.getOutInterceptors().add(new LoggingOutInterceptor());
    return bus;
}

XML configuration

<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>

<jaxws:server id="MyService" address="/ws/MyService" 
    serviceClass="com.kennie.IMyService" >
    <jaxws:serviceBean>
        <ref bean="myServiceImpl" />
    </jaxws:serviceBean>
</jaxws:server>

Service Interface

@WebService
public interface IMyService{

    @WebMethod
    public @WebResult(name = "Response") Response doRequest(
        @WebParam(name = "Request", mode = WebParam.Mode.IN)
        Request request
    );
}

Solution

  • I'm not familiar with CXF, but I know that Spring Integration HTTP is fully based on Spring MVC. So, if you can configure Spring MVC over CXF, all those Spring Integration HTTP Inbound Gateways will be available there as well.

    I think your problem is somewhere with distinguishing Servlet mapping.

    Looks like your REST API is routed through the CXF Servlet and that one doesn't like it, hence rejecting.