I have created a simple spring-boot SOAP webservice using this guide: https://spring.io/guides/gs/producing-web-service/
I am deploying it to a cloud service, but will have an API management layer in front of it.
I would like the WSDL to have the use the URL of the API management layer. (Essentially hardcode the address.)
I have tried two methods:
Use a 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;
}
Use SimpleWsdl11Definition.setWsdl() to point to a hand-edited 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;
}
I am building with Maven. In both cases, the WSDL hosted by the application replaces the host name with the server it is running on, e.g. http://localhost:8080/ and then uses the rest of the URI.
<wsdl:service name="CountriesPortService">
<wsdl:port binding="tns:CountriesPortSoap11" name="CountriesPortSoap11">
<soap:address location="http://localhost:8080/ws"/>
</wsdl:port>
</wsdl:service>
How do I set/override the hostname portion of the
I think you are using setTransformWsdlLocations(true) in messageDispatcherServlet method of your Web Service config class. This setting will transform the URLs according to the environment that it is running on. Remove this line so that it will take default setting of fals & it won't override.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With