如何在 wsdl 末尾更改 soap 地址

How to change soap address at end of wsdl

我有一个由 Apache CXF WS 生成的 WSDL,看起来像这样

<wsdl:service name="MyWS">
    <wsdl:port binding="tns:MyWSSoapBinding" name="MyWSImplPort">
        <soap:address location="http://someaddress/MyApp/ws/MyWS"/>
    </wsdl:port>
</wsdl:service>

我想将 soap:address 的协议改为 https 而不是 http

这种需求背后的原因。我们是 运行 LoadBalancer 后面 tomcat 服务器上的 SpringBootApp。负载均衡器将在地址 https://someaddress/MyApp/ws/MyWs?wsdl 上接收请求,然后通过 http 将请求转发到服务器。当 wsdl 由 Apache CXF 自动生成时,它使用 soap:address 协议 http 而不是 https.

生成它

在Application.java

@Bean
public ServletRegistrationBean servletRegistrationBean() {
   CXFServlet servlet = new CXFServlet();
   return new ServletRegistrationBean(servlet, "/MyApp/ws/*");
}

@Bean
@Autowired
public Endpoint submitAssessment(ApplicationContext context, MyWS myWS) {
   Bus cxfBus = (Bus)context.getBean(Bus.DEFAULT_BUS_ID);
   EndpointImpl endpoint = new EndpointImpl(cxfBus, myWS);
   endpoint.setAddress("/MyWS");
   cxfBus.getInInterceptors().add(new LoggingInInterceptor());
   endpoint.publish();
   return endpoint;
}

关于我的服务实现

@Service
@WebService(serviceName = "MyWS", name = "MyWSPortType", portName = "MyWSPort", )
public class MyWSImpl implements MyWS {

参数 "publishedEndpointURL" 与您要搜索的参数相似。

参见: http://cxf.apache.org/docs/jax-ws-configuration.html