Spring Web Services Framework

org.springframework.ws.transport.http
Class WsdlDefinitionHandlerAdapter

java.lang.Object
  extended by org.springframework.xml.transform.TransformerObjectSupport
      extended by org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter
All Implemented Interfaces:
InitializingBean, HandlerAdapter

public class WsdlDefinitionHandlerAdapter
extends TransformerObjectSupport
implements HandlerAdapter, InitializingBean

Adapter to use the WsdlDefinition interface with the generic DispatcherServlet.

Reads the source from the mapped WsdlDefinition implementation, and writes that as the result to the HttpServletResponse.

If the property transformLocations is set to true, this adapter will change location attributes in the WSDL definition to reflect the URL of the incoming request. If the location field in the original WSDL is an absolute path, the scheme, hostname, and port will be changed. If the location is a relative path, the scheme, hostname, port, and context path will be prepended. This behavior can be customized by overriding the transformLocation() method.

For instance, if the location attribute defined in the WSDL is http://localhost:8080/context/services/myService, and the request URI for the WSDL is http://example.com/context/myService.wsdl, the location will be changed to http://example.com/context/services/myService.

If the location attribute defined in the WSDL is /services/myService, and the request URI for the WSDL is http://example.com:8080/context/myService.wsdl, the location will be changed to http://example.com:8080/context/services/myService.

When transformLocations is enabled, all location attributes found in the WSDL definition are changed by default. This behavior can be customized by changing the locationExpression property, which is an XPath expression that matches the attributes to change.

Since:
1.0.0
Author:
Arjen Poutsma
See Also:
WsdlDefinition, setTransformLocations(boolean), setLocationExpression(String), transformLocation(String,javax.servlet.http.HttpServletRequest)

Field Summary
static String DEFAULT_LOCATION_EXPRESSION
          Default XPath expression used for extracting all location attributes from the WSDL definition.
 
Constructor Summary
WsdlDefinitionHandlerAdapter()
           
 
Method Summary
 void afterPropertiesSet()
           
 long getLastModified(HttpServletRequest request, Object handler)
           
 ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
           
 void setLocationExpression(String locationExpression)
          Sets the XPath expression used for extracting the location attributes from the WSDL 1.1 definition.
 void setTransformLocations(boolean transformLocations)
          Sets whether relative address locations in the WSDL are to be transformed using the request URI of the incoming HttpServletRequest.
 boolean supports(Object handler)
           
protected  String transformLocation(String location, HttpServletRequest request)
          Transform the given location string to reflect the given request.
protected  void transformLocations(Document definitionDocument, HttpServletRequest request)
          Transforms all location attributes to reflect the server name given HttpServletRequest.
 
Methods inherited from class org.springframework.xml.transform.TransformerObjectSupport
createTransformer, getTransformerFactory, newTransformerFactory, setTransformerFactoryClass, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LOCATION_EXPRESSION

public static final String DEFAULT_LOCATION_EXPRESSION
Default XPath expression used for extracting all location attributes from the WSDL definition.

See Also:
Constant Field Values
Constructor Detail

WsdlDefinitionHandlerAdapter

public WsdlDefinitionHandlerAdapter()
Method Detail

setLocationExpression

public void setLocationExpression(String locationExpression)
Sets the XPath expression used for extracting the location attributes from the WSDL 1.1 definition.

Defaults to DEFAULT_LOCATION_EXPRESSION.

See Also:
DEFAULT_LOCATION_EXPRESSION

setTransformLocations

public void setTransformLocations(boolean transformLocations)
Sets whether relative address locations in the WSDL are to be transformed using the request URI of the incoming HttpServletRequest. Defaults to false.


getLastModified

public long getLastModified(HttpServletRequest request,
                            Object handler)
Specified by:
getLastModified in interface HandlerAdapter

handle

public ModelAndView handle(HttpServletRequest request,
                           HttpServletResponse response,
                           Object handler)
                    throws Exception
Specified by:
handle in interface HandlerAdapter
Throws:
Exception

supports

public boolean supports(Object handler)
Specified by:
supports in interface HandlerAdapter

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

transformLocation

protected String transformLocation(String location,
                                   HttpServletRequest request)
Transform the given location string to reflect the given request. If the given location is a full url, the scheme, server name, and port are changed. If it is a relative url, the scheme, server name, and port are prepended. Can be overridden in subclasses to change this behavior.

For instance, if the location attribute defined in the WSDL is http://localhost:8080/context/services/myService, and the request URI for the WSDL is http://example.com:8080/context/myService.wsdl, the location will be changed to http://example.com:8080/context/services/myService.

If the location attribute defined in the WSDL is /services/myService, and the request URI for the WSDL is http://example.com:8080/context/myService.wsdl, the location will be changed to http://example.com:8080/context/services/myService.

This method is only called when the transformLocations property is true.


transformLocations

protected void transformLocations(Document definitionDocument,
                                  HttpServletRequest request)
                           throws Exception
Transforms all location attributes to reflect the server name given HttpServletRequest. Determines the suitable attributes by evaluating the defined XPath expression, and delegates to transformLocation to do the transformation for all attributes that match.

This method is only called when the transformLocations property is true.

Throws:
Exception
See Also:
setLocationExpression(String), setTransformLocations(boolean), transformLocation(String,javax.servlet.http.HttpServletRequest)

Spring Web Services Framework

Copyright © 2005-2010 The Spring Web Services Framework. All Rights Reserved.