【发布时间】:2018-02-14 17:43:23
【问题描述】:
我使用本指南创建了一个简单的 spring-boot SOAP webservice: https://spring.io/guides/gs/producing-web-service/
我将它部署到云服务,但前面会有一个 API 管理层。
我希望 WSDL 能够使用 API 管理层的 URL。 (本质上是对地址进行硬编码。)
我尝试了两种方法:
-
使用 DefaultWsdl11Definition.setLocationUri()
@Bean(name = "countries") public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) { DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); wsdl11Definition.setPortTypeName("CountriesPort"); wsdl11Definition.setLocationUri("http://example.com/ws"); wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service"); wsdl11Definition.setSchema(countriesSchema); return wsdl11Definition; } -
使用 SimpleWsdl11Definition.setWsdl() 指向手动编辑的 WSDL
@Bean(name = "countries") public SimpleWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) { SimpleWsdl11Definition wsdl11Definition = new SimpleWsdl11Definition(); wsdl11Definition.setWsdl(new ClassPathResource("countries.wsdl")); //this WSDL was edited to have the path I want return wsdl11Definition; }
我正在使用 Maven 构建。在这两种情况下,应用程序托管的 WSDL 都将主机名替换为运行它的服务器,例如http://localhost:8080/,然后使用 URI 的其余部分。
<wsdl:service name="CountriesPortService">
<wsdl:port binding="tns:CountriesPortSoap11" name="CountriesPortSoap11">
<soap:address location="http://localhost:8080/ws"/>
</wsdl:port>
</wsdl:service>
如何设置/覆盖
的主机名部分【问题讨论】:
标签: spring-boot soap wsdl