Spring Web Services Framework

org.springframework.ws.wsdl.wsdl11.builder
Class XsdBasedSoap11Wsdl4jDefinitionBuilder

java.lang.Object
  extended by org.springframework.ws.wsdl.wsdl11.builder.AbstractWsdl4jDefinitionBuilder
      extended by org.springframework.ws.wsdl.wsdl11.builder.AbstractBindingWsdl4jDefinitionBuilder
          extended by org.springframework.ws.wsdl.wsdl11.builder.AbstractSoap11Wsdl4jDefinitionBuilder
              extended by org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder
All Implemented Interfaces:
InitializingBean, Wsdl11DefinitionBuilder

public class XsdBasedSoap11Wsdl4jDefinitionBuilder
extends AbstractSoap11Wsdl4jDefinitionBuilder
implements InitializingBean

Builds a WsdlDefinition with a SOAP 1.1 binding based on an XSD schema. This builder iterates over all elements found in the schema, and creates a message for those elements that end with the request or response suffix. It combines these messages into operations, and builds a portType based on the operations.

By default, the schema file is inlined in a types block. However, if the schemaLocation property is set, an XSD import is used instead. As such, the imported schema file can contain further imports, which will be resolved correctly in accordance with the schema location.

To create messages from imported and included schemas, set the followIncludeImport property to true.

Typically used within a DynamicWsdl11Definition, like so:

 <bean id="airline" class="org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition">
   <property name="builder">
     <bean class="org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder">
     <property name="schema" value="/WEB-INF/airline.xsd"/>
     <property name="portTypeName" value="Airline"/>
     <property name="locationUri" value="http://localhost:8080/airline/services"/>
     </bean>
   </property>
 </bean>
 

Requires the schema and portTypeName properties to be set.

Since:
1.0.0
Author:
Arjen Poutsma
See Also:
setSchema(org.springframework.core.io.Resource), setPortTypeName(String), setRequestSuffix(String), setResponseSuffix(String)

Field Summary
static String DEFAULT_FAULT_SUFFIX
          The default suffix used to detect fault elements in the schema.
static String DEFAULT_PREFIX
          The default prefix used to register the target namespace in the WSDL.
static String DEFAULT_REQUEST_SUFFIX
          The default suffix used to detect request elements in the schema.
static String DEFAULT_RESPONSE_SUFFIX
          The default suffix used to detect response elements in the schema.
static String DEFAULT_SCHEMA_PREFIX
          The default prefix used to register the schema namespace in the WSDL.
static String SERVICE_SUFFIX
          The suffix used to create a service name from a port type name.
 
Fields inherited from class org.springframework.ws.wsdl.wsdl11.builder.AbstractSoap11Wsdl4jDefinitionBuilder
DEFAULT_TRANSPORT_URI
 
Fields inherited from class org.springframework.ws.wsdl.wsdl11.builder.AbstractWsdl4jDefinitionBuilder
logger
 
Constructor Summary
XsdBasedSoap11Wsdl4jDefinitionBuilder()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  void buildImports(Definition definition)
          Does nothing.
protected  void buildMessages(Definition definition)
          Creates messages for each element found in the schema for which isRequestMessage(), isResponseMessage(), or isFaultMessage() is true.
protected  void buildPortTypes(Definition definition)
          Adds port types to the definition.
protected  void buildTypes(Definition definition)
          Creates a Types object containing a Schema.
protected  QName getFaultMessageName(QName requestMessageName)
          Given an request message name, return the corresponding fault message name.
protected  QName getResponseMessageName(QName requestMessageName)
          Given an request message name, return the corresponding response message name.
protected  boolean isFaultMessage(QName name)
          Indicates whether the given name should be included as Message in the definition.
protected  boolean isRequestMessage(QName name)
          Indicates whether the given name name should be included as request Message in the definition.
protected  boolean isResponseMessage(QName name)
          Indicates whether the given name should be included as Message in the definition.
protected  void populateDefinition(Definition definition)
          Adds the target namespace and schema namespace to the definition.
protected  void populateMessage(Message message, QName elementName)
          Called after the Message has been created.
protected  void populateOperation(Operation operation, Message requestMessage, Message responseMessage)
          Called after the Operation has been created.
protected  void populatePart(Part part, QName elementName)
          Called after the Part has been created.
protected  void populatePortType(PortType portType)
          Called after the PortType has been created.
protected  void populateService(Service service)
          Sets the name of the service to the name of the port type, with "Service" appended to it.
 void setFaultSuffix(String faultSuffix)
          Sets the suffix used to detect fault elements in the schema.
 void setFollowIncludeImport(boolean followIncludeImport)
          Indicates whether schema <xsd:include/> and <xsd:import/> should be followed.
 void setPortTypeName(String portTypeName)
          Sets the port type name used for this definition.
 void setPrefix(String prefix)
          Sets the prefix used to declare the target namespace.
 void setRequestSuffix(String requestSuffix)
          Sets the suffix used to detect request elements in the schema.
 void setResponseSuffix(String responseSuffix)
          Sets the suffix used to detect response elements in the schema.
 void setSchema(Resource schemaResource)
          Sets the XSD schema to use for generating the WSDL.
 void setSchemaLocation(String schemaLocation)
          Sets the location of the schema to import.
 void setSchemaPrefix(String schemaPrefix)
          Sets the prefix used to declare the schema target namespace.
 void setTargetNamespace(String targetNamespace)
          Sets the target namespace used for this definition.
 
Methods inherited from class org.springframework.ws.wsdl.wsdl11.builder.AbstractSoap11Wsdl4jDefinitionBuilder
createSoapExtension, populateBinding, populateBindingFault, populateBindingInput, populateBindingOperation, populateBindingOutput, populatePort, populateSoapAddress, populateSoapBinding, populateSoapBody, populateSoapFault, populateSoapOperation, setLocationUri, setTransportUri
 
Methods inherited from class org.springframework.ws.wsdl.wsdl11.builder.AbstractBindingWsdl4jDefinitionBuilder
buildBindings, buildServices
 
Methods inherited from class org.springframework.ws.wsdl.wsdl11.builder.AbstractWsdl4jDefinitionBuilder
buildBindings, buildDefinition, buildImports, buildMessages, buildPortTypes, buildServices, buildTypes, createExtension, getDefinition, populateExtensionRegistry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_REQUEST_SUFFIX

public static final String DEFAULT_REQUEST_SUFFIX
The default suffix used to detect request elements in the schema.

See Also:
Constant Field Values

DEFAULT_RESPONSE_SUFFIX

public static final String DEFAULT_RESPONSE_SUFFIX
The default suffix used to detect response elements in the schema.

See Also:
Constant Field Values

DEFAULT_FAULT_SUFFIX

public static final String DEFAULT_FAULT_SUFFIX
The default suffix used to detect fault elements in the schema.

See Also:
Constant Field Values

DEFAULT_SCHEMA_PREFIX

public static final String DEFAULT_SCHEMA_PREFIX
The default prefix used to register the schema namespace in the WSDL.

See Also:
Constant Field Values

DEFAULT_PREFIX

public static final String DEFAULT_PREFIX
The default prefix used to register the target namespace in the WSDL.

See Also:
Constant Field Values

SERVICE_SUFFIX

public static final String SERVICE_SUFFIX
The suffix used to create a service name from a port type name.

See Also:
Constant Field Values
Constructor Detail

XsdBasedSoap11Wsdl4jDefinitionBuilder

public XsdBasedSoap11Wsdl4jDefinitionBuilder()
Method Detail

setRequestSuffix

public void setRequestSuffix(String requestSuffix)
Sets the suffix used to detect request elements in the schema.

See Also:
DEFAULT_REQUEST_SUFFIX

setResponseSuffix

public void setResponseSuffix(String responseSuffix)
Sets the suffix used to detect response elements in the schema.

See Also:
DEFAULT_RESPONSE_SUFFIX

setFaultSuffix

public void setFaultSuffix(String faultSuffix)
Sets the suffix used to detect fault elements in the schema.

See Also:
DEFAULT_FAULT_SUFFIX

setPortTypeName

public void setPortTypeName(String portTypeName)
Sets the port type name used for this definition. Required.


setTargetNamespace

public void setTargetNamespace(String targetNamespace)
Sets the target namespace used for this definition.


setSchemaPrefix

public void setSchemaPrefix(String schemaPrefix)
Sets the prefix used to declare the schema target namespace.

See Also:
DEFAULT_SCHEMA_PREFIX

setPrefix

public void setPrefix(String prefix)
Sets the prefix used to declare the target namespace.

See Also:
DEFAULT_PREFIX

setSchema

public void setSchema(Resource schemaResource)
Sets the XSD schema to use for generating the WSDL.


setSchemaLocation

public void setSchemaLocation(String schemaLocation)
Sets the location of the schema to import. If this property is set, the schema element in the generated WSDL will only contain an import, referring to the value of this property.


setFollowIncludeImport

public void setFollowIncludeImport(boolean followIncludeImport)
Indicates whether schema <xsd:include/> and <xsd:import/> should be followed. Default is false.


afterPropertiesSet

public final void afterPropertiesSet()
                              throws IOException,
                                     ParserConfigurationException,
                                     SAXException
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
IOException
ParserConfigurationException
SAXException

populateDefinition

protected void populateDefinition(Definition definition)
                           throws WSDLException
Adds the target namespace and schema namespace to the definition.

Overrides:
populateDefinition in class AbstractSoap11Wsdl4jDefinitionBuilder
Parameters:
definition - the WSDL4J Definition
Throws:
WSDLException - in case of errors
See Also:
AbstractWsdl4jDefinitionBuilder.buildDefinition()

buildImports

protected void buildImports(Definition definition)
                     throws WSDLException
Does nothing.

Specified by:
buildImports in class AbstractWsdl4jDefinitionBuilder
Parameters:
definition - the WSDL4J Definition
Throws:
WSDLException - in case of errors

buildTypes

protected void buildTypes(Definition definition)
                   throws WSDLException
Creates a Types object containing a Schema. By default, the schema set by the schema property will be inlined into this type. If the schemaLocation is set, object that is populated with the types found in the schema.

Specified by:
buildTypes in class AbstractWsdl4jDefinitionBuilder
Parameters:
definition - the WSDL4J Definition
Throws:
WSDLException - in case of errors

buildMessages

protected void buildMessages(Definition definition)
                      throws WSDLException
Creates messages for each element found in the schema for which isRequestMessage(), isResponseMessage(), or isFaultMessage() is true.

Specified by:
buildMessages in class AbstractWsdl4jDefinitionBuilder
Parameters:
definition - the WSDL4J Definition
Throws:
WSDLException - in case of errors
See Also:
isRequestMessage(javax.xml.namespace.QName), isResponseMessage(javax.xml.namespace.QName), isFaultMessage(javax.xml.namespace.QName)

isRequestMessage

protected boolean isRequestMessage(QName name)
Indicates whether the given name name should be included as request Message in the definition. Default implementation checks whether the local part ends with the request suffix.

Parameters:
name - the name of the element elligable for being a message
Returns:
true if to be included as message; false otherwise
See Also:
setRequestSuffix(String)

isResponseMessage

protected boolean isResponseMessage(QName name)
Indicates whether the given name should be included as Message in the definition. Default implementation checks whether the local part ends with the response suffix.

Parameters:
name - the name of the element elligable for being a message
Returns:
true if to be included as message; false otherwise
See Also:
setResponseSuffix(String)

isFaultMessage

protected boolean isFaultMessage(QName name)
Indicates whether the given name should be included as Message in the definition. Default implementation checks whether the local part ends with the fault suffix.

Parameters:
name - the name of the element elligable for being a message
Returns:
true if to be included as message; false otherwise
See Also:
setFaultSuffix(String)

populateMessage

protected void populateMessage(Message message,
                               QName elementName)
                        throws WSDLException
Called after the Message has been created.

Default implementation sets the name of the message to the element name.

Parameters:
message - the WSDL4J Message
elementName - the element name
Throws:
WSDLException - in case of errors

populatePart

protected void populatePart(Part part,
                            QName elementName)
                     throws WSDLException
Called after the Part has been created.

Default implementation sets the element name of the part.

Parameters:
part - the WSDL4J Part
elementName - the elementName
Throws:
WSDLException - in case of errors
See Also:
Part.setElementName(javax.xml.namespace.QName)

buildPortTypes

protected void buildPortTypes(Definition definition)
                       throws WSDLException
Description copied from class: AbstractWsdl4jDefinitionBuilder
Adds port types to the definition.

Specified by:
buildPortTypes in class AbstractWsdl4jDefinitionBuilder
Parameters:
definition - the WSDL4J Definition
Throws:
WSDLException - in case of errors

populatePortType

protected void populatePortType(PortType portType)
                         throws WSDLException
Called after the PortType has been created.

Default implementation sets the name of the port type to the defined value.

Parameters:
portType - the WSDL4J PortType
Throws:
WSDLException - in case of errors
See Also:
setPortTypeName(String)

getResponseMessageName

protected QName getResponseMessageName(QName requestMessageName)
Given an request message name, return the corresponding response message name.

Default implementation removes the request suffix, and appends the response suffix.

Parameters:
requestMessageName - the name of the request message
Returns:
the name of the corresponding response message, or null

getFaultMessageName

protected QName getFaultMessageName(QName requestMessageName)
Given an request message name, return the corresponding fault message name.

Default implementation removes the request suffix, and appends the fault suffix.

Parameters:
requestMessageName - the name of the request message
Returns:
the name of the corresponding response message, or null

populateOperation

protected void populateOperation(Operation operation,
                                 Message requestMessage,
                                 Message responseMessage)
                          throws WSDLException
Called after the Operation has been created.

Default implementation sets the name of the operation to name of the messages, without suffix.

Parameters:
operation - the WSDL4J Operation
requestMessage - the WSDL4J request Message
responseMessage - the WSDL4J response Message
Throws:
WSDLException - in case of errors
See Also:
setPortTypeName(String)

populateService

protected void populateService(Service service)
                        throws WSDLException
Sets the name of the service to the name of the port type, with "Service" appended to it.

Overrides:
populateService in class AbstractBindingWsdl4jDefinitionBuilder
Parameters:
service - the WSDL4J Service
Throws:
WSDLException - in case of errors

Spring Web Services Framework

Copyright � 2005-2008 The Spring Web Services Framework. All Rights Reserved.