9.2. Automatic WSDL Generation

Opal 2.2 and higher, optionally supports automatic WSDL generation, based on the types element in the application metadata. This code has been contributed to the Opal SVN by Anthony Bretaudeau from IRISA. This has been implemented in a minimally invasive fashion. If automatic WSDL generation is enabled, Opal services can be accesed using their regular non-typed standard WSDL and the newly autogenerated strongly-typed WSDL simultaneously. This will enable all legacy clients to continue to use the old-style WSDL, while clients that prefer a stronger typed WSDL can use the autogenerated version.

Similarly to the automatic interface generation using the types element in the application metadata, an updated WSDL is generated during service deployment time (using XSLT), using a simple rule-based translation. For instance, an argument specified as a flag below:

            <flag>
                <id>verbose</id>
                <tag>--verbose</tag>
                <textDesc>Provide verbose output</textDesc>
                <default>true</default>
            </flag>

is translated into a boolean XML element as follows:

	    <xsd:element maxOccurs="1" minOccurs="0" name="verbose" type="xsd:boolean" default="true">
                <xsd:annotation>
                    <xsd:documentation>Provide verbose output</xsd:documentation>
                </xsd:annotation>
	    </xsd:element>

An untagged parameter is translated into an XML element of an appropriate type. For example, an untagged parameter of paramType STRING will be converted into an XML element of type xsd:string. Untagged parameters are translated into an xsd:sequence of appropriately typed elements.

To enable automatic interface generation, uncomment the typedservices.dir property within the build.properties as follows:

# location of the typed services directory relative to $CATALINA_HOME/webapps.
# uncomment if you want to generate typed WSDL for services
typedservices.dir = opal2/typedservices

Also uncomment the following lines in the webapps/opal2/WEB-INF/web.xml to enable the SOAP filter that performs the conversion from the regular untyped Opal WSDL to the new WSDL.

  <filter> 
    <filter-name>OpalSOAPRequestFilter</filter-name> 
    <filter-class>org.inria.genouest.opal.tools.soaprequest.filter.OpalSOAPRequestFilter</filter-class> 
  </filter> 
  <filter-mapping> 
    <filter-name>OpalSOAPRequestFilter</filter-name> 
    <servlet-name>AxisServlet</servlet-name> 
  </filter-mapping>

Now re-deploy Opal by running ant install and restart Tomcat. Now you can continue to deploy Opal services using the ant deploy command, and it will print out the URL of the autogenerated WSDL that you may share with clients. Note that it only makes sense to autogenerate WSDL's if the application configuration has the correct types specified. If the types have not been specified, you may continue to use the regular legacy-style non-typed WSDLs.