I'm struggling with a Spring-WS route I'd like to add in my Spring-boot application. I keep getting the following exception on startup:
Caused by: java.lang.IllegalArgumentException: No instance of CamelSpringWSEndpointMapping found in Spring ApplicationContext. This bean is required for Spring-WS consumer support (unless the 'spring-ws:beanname:' URI scheme is used)
at org.apache.camel.component.spring.ws.SpringWebserviceComponent.addEndpointMappingToConfiguration(SpringWebserviceComponent.java:142)
at org.apache.camel.component.spring.ws.SpringWebserviceComponent.addConsumerConfiguration(SpringWebserviceComponent.java:83)
at org.apache.camel.component.spring.ws.SpringWebserviceComponent.createEndpoint(SpringWebserviceComponent.java:67)
at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:114)
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:568)
... 40 common frames omitted
This is very odd, as I explicitly add the CamelEndpointMapping (which extends from CamelSpringWSEndpointMapping) in my Spring configuration like this:
@EnableWs
@SpringBootApplication
public class Application
{
public static void main(String[] args)
{
SpringApplication.run(Application.class, args);
}
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext)
{
MessageDispatcherServlet messageDispatcherServlet = new MessageDispatcherServlet();
messageDispatcherServlet.setApplicationContext(applicationContext);
messageDispatcherServlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(messageDispatcherServlet, "/soap/*");
}
@Bean
public CamelEndpointMapping endpointMapping()
{
return new CamelEndpointMapping();
}
}
My route:
@Component
public class MyRoutes extends RouteBuilder
{
@Override
public void configure() throws Exception
{
from("spring-ws:soapaction:http://example.com/myservice")
.to("log:cameltest?level=DEBUG");
}
}
What am I doing wrong here? You can find full source of my sample project on GitHub: https://github.com/verhage/cameltest
It looks like the error message is misleading.
Your URL needs to look like this:
spring-ws:soapaction:XXX?endpointMapping=endpointMapping
(found by debugging SpringWebserviceComponent.addConsumerConfiguration and stepping through)