Skip to content

I can't set transformSchemaLocation attribute in MessageDispatcherServlet class through web.xml file [SWS-840] #914

@gregturn

Description

@gregturn

Thiago Gutenberg Carvalho da Costa opened SWS-840 and commented

In my Spring XML file I have a static-wsdl defined and in the WSDL I imported a XML Schema Definition with namespace and schemaLocation attributes.

When I deploy my Web Application I want to the xml <soap:address location /> and ```xml <xs:import schemaLocation />


So to achieve this behavior in the web.xml file I have this configuration:

```xml 
<servlet>
   <servlet-name>spring-ws-dispatcher</servlet-name>
   <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
      <init-param>
         <param-name>transformWsdlLocations</param-name>
         <param-value>true</param-value>
      </init-param>
      <init-param>
         <param-name>transformSchemaLocations</param-name>
         <param-value>true</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
    </servlet>

The problem:

When the application is deployed, the method 'initWsdlDefinitionHandlerAdapter' in class 'MessageDispatcherServlet' runs, but only the attribute transformLocations in class 'WsdlDefinitionHandlerAdapter' is properly setted with the value passed through the ```xml <init-param />

``` transformSchemaLocations 
``` is not. As can be seen in red in the code below:

private void initWsdlDefinitionHandlerAdapter(ApplicationContext context) {
try {
try {
wsdlDefinitionHandlerAdapter = context.getBean(getWsdlDefinitionHandlerAdapterBeanName(), WsdlDefinitionHandlerAdapter.class);

  } catch (NoSuchBeanDefinitionException ignored) {
       wsdlDefinitionHandlerAdapter = new WsdlDefinitionHandlerAdapter();
  }

  wsdlDefinitionHandlerAdapter.setTransformLocations(isTransformWsdlLocations());

  wsdlDefinitionHandlerAdapter.afterPropertiesSet();

} catch (Exception ex) {
throw new BeanInitializationException("Could not initialize WsdlDefinitionHandlerAdapter", ex);
}
}


My solution was: 

Create in the Spring XML file a wsdlDefinitionHandlerAdapter bean and set the properties 'transformLocations' and 'transformSchemaLocations' with value true.

<bean id="wsdlDefinitionHandlerAdapter" class="org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter">
<property name="transformSchemaLocations" value="true" />
<property name="transformLocations" value="true" />
</bean>



---

**Affects:** 2.1.3

**Referenced from:** commits https://github.com/spring-projects/spring-ws/commit/18717fa4d087483b9ce0882b14e55e7d6420fd27

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions