Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override entire address in WSDL

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:

  1. 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;
    }
    
  2. 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

like image 859
user9361372 Avatar asked Feb 14 '18 17:02

user9361372


1 Answers

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.

like image 183
user2553467 Avatar answered Sep 18 '22 14:09

user2553467