From 5f79616f272a40a4316f7a681f47a9b10df5e07a Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Wed, 7 Nov 2012 10:52:15 +0000 Subject: [PATCH] SWS-797 - XsdSchemaHandlerAdapter does not transform schema locations --- .../http/MessageDispatcherServlet.java | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java b/core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java index ba1e368f..ddc42cc7 100644 --- a/core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java +++ b/core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java @@ -1,5 +1,5 @@ /* - * Copyright 2005-2011 the original author or authors. + * Copyright 2005-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanInitializationException; import org.springframework.beans.factory.BeanNameAware; -import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.context.ApplicationContext; import org.springframework.web.servlet.DispatcherServlet; @@ -119,6 +118,8 @@ public class MessageDispatcherServlet extends FrameworkServlet { private boolean transformWsdlLocations = false; + private boolean transformSchemaLocations = false; + /** Public constructor, necessary for some Web application servers. */ public MessageDispatcherServlet() { defaultStrategiesHelper = new DefaultStrategiesHelper(MessageDispatcherServlet.class); @@ -158,6 +159,30 @@ public class MessageDispatcherServlet extends FrameworkServlet { return transformWsdlLocations; } + /** + * Sets whether relative address locations in the WSDL are to be transformed using the request URI of the incoming + * {@link HttpServletRequest}. Defaults to false. + */ + public void setTransformWsdlLocations(boolean transformWsdlLocations) { + this.transformWsdlLocations = transformWsdlLocations; + } + + /** + * Indicates whether relative address locations in the XSD are to be transformed using the request URI of the + * incoming {@link HttpServletRequest}. + */ + public boolean isTransformSchemaLocations() { + return transformSchemaLocations; + } + + /** + * Sets whether relative address locations in the XSD are to be transformed using the request URI of the incoming + * {@link HttpServletRequest}. Defaults to false. + */ + public void setTransformSchemaLocations(boolean transformSchemaLocations) { + this.transformSchemaLocations = transformSchemaLocations; + } + /** Returns the bean name used to lookup a {@link WebServiceMessageReceiverHandlerAdapter}. */ public String getMessageReceiverHandlerAdapterBeanName() { return messageReceiverHandlerAdapterBeanName; @@ -197,13 +222,6 @@ public class MessageDispatcherServlet extends FrameworkServlet { this.xsdSchemaHandlerAdapterBeanName = xsdSchemaHandlerAdapterBeanName; } - /** - * Sets whether relative address locations in the WSDL are to be transformed using the request URI of the incoming - * {@link HttpServletRequest}. Defaults to false. - */ - public void setTransformWsdlLocations(boolean transformWsdlLocations) { - this.transformWsdlLocations = transformWsdlLocations; - } @Override protected void doService(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) @@ -363,9 +381,8 @@ public class MessageDispatcherServlet extends FrameworkServlet { catch (NoSuchBeanDefinitionException ignored) { xsdSchemaHandlerAdapter = new XsdSchemaHandlerAdapter(); } - if (xsdSchemaHandlerAdapter instanceof InitializingBean) { - ((InitializingBean) xsdSchemaHandlerAdapter).afterPropertiesSet(); - } + xsdSchemaHandlerAdapter.setTransformSchemaLocations(isTransformSchemaLocations()); + xsdSchemaHandlerAdapter.afterPropertiesSet(); } catch (Exception ex) { throw new BeanInitializationException("Could not initialize XsdSchemaHandlerAdapter", ex);