Сопоставить несколько URL-адресов в приложении Spring Boot SOAP - PullRequest
0 голосов
/ 18 ноября 2018

Предположим, что у меня есть 2 URL и 2 Endpoint Service.Я хочу направить Если URL-адрес 1 называется -> Служба маршрутизации 1, URL-адрес 2 называется -> Служба маршрутизации 2

Это слишком просто в службе отдыха, но я не знаю, как с этим справиться при загрузке SpringПриложение SOAP.

Мой класс конфигурации:

public class WebServiceConfig extends WsConfigurerAdapter {
    @Bean
    public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
        MessageDispatcherServlet servlet = new MessageDispatcherServlet();
        servlet.setApplicationContext(applicationContext);
        servlet.setTransformWsdlLocations(true);
        return new ServletRegistrationBean(servlet, "/getAll/","/getValueByKey/");
    }

    @Bean(name = "getAll")
    public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema reqRespSchema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("PrototypePortAll");
        wsdl11Definition.setLocationUri("/getAll/");
        wsdl11Definition.setTargetNamespace("acc");
        wsdl11Definition.setSchema(reqRespSchema);
        return wsdl11Definition;
    }

    @Bean
    public XsdSchema reqRespSchema() {
        return new SimpleXsdSchema(new ClassPathResource("getAll.xsd"));
    }


    @Bean(name = "getValueByKey")
    public DefaultWsdl11Definition defaultWsdl11Definition2(XsdSchema reqRespSchema2) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("PrototypePort");
        wsdl11Definition.setLocationUri("/getValueByKey/");
        wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service");
        wsdl11Definition.setSchema(reqRespSchema2);
        return wsdl11Definition;
    }

    @Bean
    public XsdSchema reqRespSchema2() {
        return new SimpleXsdSchema(new ClassPathResource("getValueByKey.xsd"));
    }
}

Мой класс конечной точки:

@Endpoint
public class PrototypeEndpoint {
    private static final String NAMESPACE_URI = "http://spring.io/guides/gs-producing-web-service";

    @Autowired
    private Services service;

    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "PrototypeRequest")
    @ResponsePayload
    public PrototypeResponse getValueByKey(@RequestPayload PrototypeRequest prototypeRequest) {
        PrototypeResponse response = new PrototypeResponse();

        HashMap<String, String> map = service.map;

        response.setValue(map.get(prototypeRequest.getName()));

        return response;

    }



    @PayloadRoot(namespace = "acc", localPart = "PrototypeRequestAll")
    @ResponsePayload
    public PrototypeResponseAll getAllValue(@RequestPayload PrototypeRequestAll prototypeRequestAll) {
        PrototypeResponseAll response = new PrototypeResponseAll();

        List<String> resultList=new ArrayList<>();

          service.map.entrySet().forEach(index->resultList.add(index.getValue()));
        response.setValue(resultList);
        return response;
    }
    }

Примечание. У меня есть два файла .xsd для каждой конечной точки.

Мне нужна помощь.Спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...