我正在使用 Apache CXF 和 Spring Boot 來公開 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
前綴)。
這些檔案是在開始時生成的,這不是硬編碼的。
uj5u.com熱心網友回復:
我還沒有找到解決方案,而是一種解決方法。有這個配置指南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: 10000
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/507597.html