首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在WSDL中替换CXF基url

如何在WSDL中替换CXF基url
EN

Stack Overflow用户
提问于 2022-07-21 16:42:09
回答 1查看 77关注 0票数 0

我使用Apache和Spring公开SOAP端点。下面是配置:

代码语言:javascript
复制
@Slf4j
@Configuration
public class SoapWebServiceConfig {

    @Bean(name = "cxf")
    public SpringBus springBus() {
        var loggingFeature = new LoggingFeature();
        loggingFeature.addSensitiveProtocolHeaderNames(Set.of("Server", "Accept", "Date"));
        loggingFeature.setPrettyLogging(true);

        var springBus = new SpringBus();
        springBus.getFeatures().add(loggingFeature);
        return springBus;
    }

    @Bean
    public ActivateGateway activateGateway() {
        return new ActivateGatewayImpl();
    }

    @Bean
    @SneakyThrows
    public Endpoint activateGatewayEndpoint(Bus bus, ActivateGateway activateGateway) {
        EndpointImpl endpoint = new EndpointImpl(bus, activateGateway);
        endpoint.publish("/activateGateway");
        return endpoint;
    }

    @Primary
    @Bean(name = "cxfServletRegistration")
    public ServletRegistrationBean<CXFServlet> cxfServletRegistration() {
        ServletRegistrationBean<CXFServlet> servletRegistrationBean = new ServletRegistrationBean<>(
            new CXFServlet(), "/daas/activate/*");
        servletRegistrationBean.setLoadOnStartup(1);
        return servletRegistrationBean;
    }
}

您可以看到,我公开了一个端点。在https://localhost:8081/daas/activate/activateGateway?wsdl可以到达

代码语言:javascript
复制
...
  <wsdl:import location="https://localhost:8081/daas/activate/activateGateway?wsdl=activateGateway.wsdl" namespace="http://schemas.symantec.com/cda/1.0/activateGateway">
    </wsdl:import>
  <wsdl:binding name="ActivateGatewayServiceSoapBinding" type="ns1:activateGateway">
  ...
  <wsdl:service name="ActivateGatewayService">
    <wsdl:port binding="tns:ActivateGatewayServiceSoapBinding" name="activateGatewayPort">
      <soap:address location="https://localhost:8081/daas/activate/activateGateway"/>
    </wsdl:port>
  </wsdl:service>

但是这个location="https://localhost:8081/daas/activate/activateGateway是无效的,因为这个服务在api网关后面。有没有办法改变“基本网址”?例如,对于这个https://localhost:8081/soap/daas/activate/activateGateway (请注意附加的/soap前缀)。

这些文件是在开始时生成的,这不是硬编码的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-22 15:47:45

我没有找到解决办法,而是找到了解决办法。这里有一个配置指南https://cxf.apache.org/docs/jax-ws-configuration.html,其中提到了publishedEndpointUrl,但遗憾的是,由于某些原因,它没有对我起作用。我使用的解决方案是结合server.servlet.context-path=/test和大使的重写功能:

代码语言:javascript
复制
apiVersion: getambassador.io/v2
kind: Mapping
metadata:
  name: {{ include "project.name" . }}
spec:
  prefix: /test
  rewrite: /test # <-- This
  host: {{ .Values.global.host }}
  service: {{ $service }}
  timeout_ms: 10000
  connect_timeout_ms: 10000
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73069849

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档