我使用Apache和Spring公开SOAP端点。下面是配置:
@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可以到达
...
<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前缀)。
这些文件是在开始时生成的,这不是硬编码的。
发布于 2022-07-22 15:47:45
我没有找到解决办法,而是找到了解决办法。这里有一个配置指南https://cxf.apache.org/docs/jax-ws-configuration.html,其中提到了publishedEndpointUrl,但遗憾的是,由于某些原因,它没有对我起作用。我使用的解决方案是结合server.servlet.context-path=/test和大使的重写功能:
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: 10000https://stackoverflow.com/questions/73069849
复制相似问题