Force dynamic wsdl address location to https scheme

Nowadays all web applications must be secure with https protocol. A typical scenario involve a load balancer wich redirect all incoming https connections, to application servers responding on http port

We have had a problem with wsdl dynamic address location, exposed by an old web application based on Spring MVC 3.0 behind a Load Balancer. A dynamic wsdl is created at runtime by spring-ws with the tag dynamic-wsdl in the spring-ws context:

<sws:dynamic-wsdl id="myService"  portTypeName="myServiceSoap"  
   locationUri="/ws/MyServiceService" targetNamespace="">
              <sws:xsd location="/WEB-INF/wsdl/MyService.xsd"/>

the portion of the service wsdl generated was like this:

<wsdl:service name="MySoapService">
    <wsdl:port binding="tns:MySoapSoap11" name="MySoapSoap11">        
         <soap:address location=""/>

The scheme of the address location was http instead that https. To solve this, we have to force the schema to https. We have to create a new bean in the application context:

<bean id="myServiceWsdlDefinitionHandlerAdapter" name="wsdlDefinitionHandlerAdapter" class="it.github.parmag.MyServiceWsdlDefinitionHandlerAdapter">

The name must be “wsdlDefinitionHandlerAdapter”. Then the bean could be like this:

public class MyServiceWsdlDefinitionHandlerAdapter extends WsdlDefinitionHandlerAdapter {
	public MyServiceWsdlDefinitionHandlerAdapter () {

	protected String transformLocation(String location, HttpServletRequest request) {
		String newLocation = super.transformLocation(location, request);
		newLocation = "https" + newLocation.substring(newLocation.indexOf(":"));
		return newLocation;

Now, the address location is https:

<wsdl:service name="MySoapService">
    <wsdl:port binding="tns:MySoapSoap11" name="MySoapSoap11">        
         <soap:address location=""/>


2 thoughts on “Force dynamic wsdl address location to https scheme”

  1. I cannot get this to work. Can you tell me if there’s more in the bean definition that goes in applicationContext.xml? Looks like there might be, but assuming it’s just missing the
    Also your class that extends WsdlDefinitionHandlerAdapter has a constructor for a different class.

    What I am seeing is in the logs, I now see a log about the transformation taking place:
    DEBUG o.s.w.t.h.WsdlDefinitionHandlerAdapter –
    But the loggers I put in my class do not fire.

    Liked by 1 person

    1. Hi Mark,
      you’re right for the constructor, I’ve just correct it. Then, you just have to naming your bean definition in the application context equals to “wsdlDefinitionHandlerAdapter” and you should get the https .

      Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: