I'm trying to set-up a simple CXF Web Service running on Tomcat with CXF and Spring:
I have a Web Application initializer to bootstrap the CXF servlet:
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer
{
@Override
protected void registerContextLoaderListener(ServletContext servletContext)
{
CXFServlet cxfServlet = new CXFServlet();
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("cxf", cxfServlet);
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/services/*");
}
.....
}
I have a Spring configuration class:
@Configuration
public class WebServiceConfiguration
{
@Bean
public Endpoint endPoint()
{
EndpointImpl endpoint = new EndpointImpl(cxf(), eorthoWebService());
endpoint.getHandlers().add(inboundRequestHandler());
endpoint.getHandlers().add(outboundRequestHandler());
//the below works and uses cxf's embedded Jetty server
//endpoint.publish("http://localhost:9090/services/EorthoWebService");
//this doesn't work
endpoint.publish("/EorthoWebService");
return endpoint;
}
@Bean
public SpringBus cxf()
{
return new SpringBus();
}
@Bean
public EorthoWebService eorthoWebService()
{
return new EorthoWebServiceImpl();
}
}
I have a Web Service implementation:
@WebService(endpointInterface = "com.aoa.eortho.ws.service.EorthoWebService")
@SchemaValidation(type = SchemaValidationType.IN)
public class EorthoWebServiceImpl implements EorthoWebService {
@WebMethod
public RulesEngineOrthodonticSubmissionResponseEnv processRequest(RulesEngineOrthodonticSubmissionRequestEnv requestEnvelope) {
...
}
}
When I hit /services I get the output:
No services have been found.
The only way I can it to work is by publishing as below which seems to publish it to an embedded Jetty server rather than the Tomcat instance it is deployed to:
endpoint.publish("http://localhost:9090/services/EorthoWebService");
What am I missing to get it working on Tomcat using:
endpoint.publish("/EorthoWebService");