Apache Camel Spring-WS路由未初始化

时间:2016-10-10 15:31:08

标签: java soap spring-boot apache-camel spring-ws

我正在努力使用我希望在Spring-boot应用程序中添加的Spring-WS路由。我在启动时不断收到以下异常:

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

这很奇怪,因为我在Spring配置中明确添加了CamelEndpointMapping(从CamelSpringWSEndpointMapping扩展),如下所示:

@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();
    }
}

我的路线:

@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");
    }
}

我在这里做错了什么?您可以在GitHub上找到我的示例项目的完整源代码:https://github.com/verhage/cameltest

1 个答案:

答案 0 :(得分:0)

看起来错误信息具有误导性 您的网址需要如下所示:

spring-ws:soapaction:XXX?endpointMapping=endpointMapping 

(通过调试SpringWebserviceComponent.addConsumerConfiguration找到并单步执行)