多个spring-ws服务到一个spring引导应用程序中。 Java配置

时间:2016-02-04 22:19:18

标签: spring-mvc spring-boot jax-ws spring-ws

我需要为几个远程jax-ws服务实现存根服务。它应该在一个jar应用程序下运行。所以我有服务的wsdl文件,可以将它编译成java类。使用spring教程我可以使用一个端点运行一个服务。但是我没能配置好几个服务。

问题#1是如何配置多个服务/端点在一个spring应用程序中协同工作。

问题#2如何将弹簧支撑服务添加到上述配置中(spring-boot + ws + rs)?

更新:问题#1 不知道是否正确,但我的配置是:

    @EnableWs
    @Configuration
    public class WsConfig2 extends WsConfigurerAdapter {

        @Bean(name = "firstService")
        public SimpleWsdl11Definition storelocatorServiceWsdl11Definition() {
            SimpleWsdl11Definition simpleWsdl11Definition = new SimpleWsdl11Definition();
            simpleWsdl11Definition.setWsdl(new ClassPathResource("stub/wsdl/firstService.wsdl"));
            return simpleWsdl11Definition;
        }

        @Bean(name = "secondService")
        public SimpleWsdl11Definition inventoryAvailabilityServiceWsdl11Definition() {
            SimpleWsdl11Definition simpleWsdl11Definition = new SimpleWsdl11Definition();
            simpleWsdl11Definition.setWsdl(new ClassPathResource("stub/wsdl/secondService.wsdl"));
            return simpleWsdl11Definition;
        }

        @Override
        public void addInterceptors(List<EndpointInterceptor> interceptors) {
            PayloadLoggingInterceptor payloadLoggingInterceptor = new PayloadLoggingInterceptor();
            interceptors.add(payloadLoggingInterceptor);
        }

        @Bean
        public WebServiceMessageReceiverHandlerAdapter webServiceMessageReceiverHandlerAdapter() {
            WebServiceMessageReceiverHandlerAdapter handlerAdapter = new WebServiceMessageReceiverHandlerAdapter();
            handlerAdapter.setMessageFactory(messageFactory());
            return handlerAdapter;
        }

        @Bean
        public SaajSoapMessageFactory messageFactory() {
            SaajSoapMessageFactory factory = new SaajSoapMessageFactory();
            factory.setSoapVersion(SoapVersion.SOAP_11);
            return factory;
        }

        @Bean
        public WsdlDefinitionHandlerAdapter wsdlDefinitionHandlerAdapter() {
            return new WsdlDefinitionHandlerAdapter();
        }

        @Bean
        public SoapMessageDispatcher soapMessageDispatcher() {
            return new SoapMessageDispatcher();
        }

        @Bean
        public SimpleUrlHandlerMapping simpleUrlHandlerMapping() {
            SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
            mapping.setOrder(Integer.MAX_VALUE - 2);

            Properties urlProperties = new Properties();
            urlProperties.put("/ws", "soapMessageDispatcher");
            urlProperties.put("/ws/ms/firstService", "firstService");
            urlProperties.put("/ws/ms/secondService", "secondService");

            mapping.setMappings(urlProperties);
            mapping.setDefaultHandler(soapMessageDispatcher());
            return mapping;
        }
}

但如果我向任何网址发送请求,我会收到来自相应端点的请求。

映射配置似乎有问题。

我应该以某种方式配置soapMessageDispatcher?

0 个答案:

没有答案