如何在wsdl结束时更改soap地址

时间:2016-03-04 19:14:29

标签: java web-services soap wsdl cxf

我有一个由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将请求转发给服务器。当Apache CXF自动生成wsdl时,它使用soap:地址生成它,协议为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 {

1 个答案:

答案 0 :(得分:1)

参数“publishedEndpointURL”看起来就像您正在搜索的那个。

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