【发布时间】:2019-07-30 17:58:16
【问题描述】:
我正在使用cxf-spring-boot-starter-jaxws 编写一个简单的 SOAP 服务。 WSDL 有一个服务和几个端口,看起来像这样
<wsdl:port name="myServiceSoap11Endpoint" binding="ns:myServiceSoap11Binding">
<soap:address location="http://example.com/services/myService.myServiceSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="myServiceSoap12Endpoint" binding="ns:myServiceSoap12Binding">
<soap12:address location="http://example.com/services/myService.myServiceSoap12Endpoint/"/>
</wsdl:port>
两个绑定几乎相同,并且指向相同的 PortType。
在我的 java 代码中,我使用 spring boot @Configuration 机制配置端点。我为每个端口创建一个单独的端点。
// The class MyService was auto-generated by wsdl2java
@Bean
public Endpoint endpointMyServiceSoap11() {
EndpointImpl endpoint = new EndpointImpl(springBus, new MyServiceImplementor());
endpoint.setWsdlLocation(MyService.WSDL_LOCATION.toString());
endpoint.setServiceName(MyService.SERVICE);
endpoint.setEndpointName(MyService.MyServiceSoap11Endpoint);
endpoint.publish("/myService.myServiceSoap11Endpoint");
return endpoint;
}
@Bean
public Endpoint endpointMyServiceSoap12() {
EndpointImpl endpoint = new EndpointImpl(springBus, new MyServiceImplementor());
endpoint.setWsdlLocation(MyService.WSDL_LOCATION.toString());
endpoint.setServiceName(MyService.SERVICE);
endpoint.setEndpointName(MyService.MyServiceSoap12Endpoint);
endpoint.publish("/myService.myServiceSoap12Endpoint");
return endpoint;
}
这有点工作,但是当我想要获取 WSDL 文件时问题就开始了。两个端点都作为单独的服务发布,并且都提供自己的 WSDL 版本,每个端点只有一个端口是正确的。
有没有办法将两个端点作为公共服务的一部分发布,以便/myService?WSDL 返回具有两个端点的正确 WSDL?
【问题讨论】:
标签: java spring-boot soap wsdl cxf