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="http://www.myapp.it/myapp/schema/myappws">
<sws:xsd location="/WEB-INF/wsdl/MyService.xsd"/>
</sws:dynamic-wsdl>
the portion of the service wsdl generated was like this:
<wsdl:service name="MySoapService">
<wsdl:port binding="tns:MySoapSoap11" name="MySoapSoap11">
<soap:address location="http://www.myapp.com/myapp/ws/MyService"/>
</wsdl:port>
</wsdl:service>
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 () {
}
@Override
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="https://www.myapp.com/myapp/ws/MyService"/>
</wsdl:port>
</wsdl:service>
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.
LikeLiked by 1 person
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 .
LikeLiked by 1 person