如何使用多个服务wsdl配置Spring Boot CXF配置

时间:2017-03-28 16:09:51

标签: spring spring-boot wsdl cxf config

我遇到的挑战是我有一个WSDL文件,其中包含一个服务定义

----- Customer WSDL file, can not change it ----
  <service name="DocumentOperationService">
    <port name="DocumentOperationPort" binding="tns:DocumentOperationBinding">
      <soap:address location="REPLACE_WITH_ACTUAL_URL" />
    </port>
  </service>

  <service name="PermissionEvaluatorService">
    <port name="PermissionEvaluatorPort" binding="tns:PermissionEvaluatorBinding">
      <soap:address location="REPLACE_WITH_ACTUAL_URL" />
    </port>
  </service>

  <service name="ConfigurationResolverService">
    <port name="ConfigurationResolverPort" binding="tns:ConfigurationResolverBinding">
      <soap:address location="REPLACE_WITH_ACTUAL_URL" />
    </port>
  </service>
------

如何配置Spring配置类

import org.springframework.context.annotation.Configuration;

@Configuration
public class WebServiceConfiguration {
...
    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), dmsPortService());

        // CXF JAX-WS implementation relies on the correct ServiceName as QName-Object with
        // the name-Attribute´s text <wsdl:service name="Weather"> and the targetNamespace
        // "http://www.codecentric.de/namespace/weatherservice/"
        // Also the WSDLLocation must be set
        endpoint.setServiceName(dmsOperationService().getServiceName());
        endpoint.setWsdlLocation(dmsOperationService().getWSDLDocumentLocation().toString());
//        endpoint.setWsdlLocation("classpath:/service-api-definition/journalexportservice.wsdl");
        endpoint.publish("/DocumentOperation");
        return endpoint;
    }

    @Bean
    public DocumentOperationService dmsOperationService() {
        // Needed for correct ServiceName & WSDLLocation to publish contract first incl. original WSDL
        return new DocumentOperationService();
    }

加载了所有3个服务。 目前我只能加载一个服务,我找不到任何示例如何做到这一点。 我有3个配置文件的三元组,但后来只有最后一个是活动的,以及如何在同一配置文件中配置3个服务我无法弄清楚。

1 个答案:

答案 0 :(得分:0)

您可能需要查看此tutorial,并准确描述您的确切用例。

简而言之:

  • 您的配置Bean需要提供ServletRegistrationBean cxfServletSpringBus和端点。 (非常类似于您发布的代码。来自评论的内容甚至可能来自本教程)
  • 您的端点应指向整体wdsl位置
  • 然后,您需要实现一个服务,该服务包含所有您想要的Web服务
  • 在此服务中,每个网络服务需要一种方法