Trying to deploy a JAX-WS endpoint using Tomcat 7 Maven plugin and CXF
2.7.8. As a matter of preference, I don't want to have any XML config for
Spring or CXF. I see several blogs, articles, posts using cxf-servlet.xml
and CXFServlet but none whatsoever completely using Java config. Looking into the CXFServlet source code, it looks for the cxf-servlet.xml
or anything in the servlet context under the key 'config-location'
. I tried programmatically registering the endpoint instead of in cxf-servlet.xml
, but it doesn't work; I get a 404 when accessing the service. Any ideas?
@Configuration
@ImportResource({ "classpath:META-INF/cxf/cxf.xml" })
public class CXFConfig {
@Autowired
Bus cxfBus;
// More code
@Bean
public Endpoint calculator() {
EndpointImpl endpoint = new EndpointImpl(cxfBus, new Calculator());
endpoint.setAddress("/CalculatorService");
return endpoint;
}
}