代码之家  ›  专栏  ›  技术社区  ›  Rens Verhage

Apache Camel Spring WS路由未初始化

  •  1
  • Rens Verhage  · 技术社区  · 9 年前

    我正在为我想添加到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(从camelSpringWSEndpointMaping扩展而来),如下所示:

    @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 回复  |  直到 9 年前
        1
  •  0
  •   davidfrancis    9 年前

    看起来错误消息有误导性。
    您的URL需要如下所示:

    spring-ws:soapaction:XXX?endpointMapping=endpointMapping 
    

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