Show Table of Contents
22.4. Generating WSDL
Using Maven
Once your code is annotated, you can generate a WSDL contract for your service using the
java2ws Maven plug-in's -wsdl option. For a detailed listing of options for the java2ws Maven plug-in see Section E.3, “java2ws”.
Example 22.17, “Generating WSDL from Java” shows how to set up the
java2ws Maven plug-in to generate WSDL.
Example 22.17. Generating WSDL from Java
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-java2ws-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>process-classes</id>
<phase>process-classes</phase>
<configuration>
<className>className</className>
<genWsdl>true</genWsdl>
</configuration>
<goals>
<goal>java2ws</goal>
</goals>
</execution>
</executions>
</plugin>Note
Replace the value of className with the qualified className.
Example
Example 22.18, “Generated WSDL from an SEI” shows the WSDL contract that is generated for the SEI shown in Example 22.7, “Fully Annotated SEI”.
Example 22.18. Generated WSDL from an SEI
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://demo.eric.org/"
xmlns:tns="http://demo.eric.org/"
xmlns:ns1=""
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns2="http://demo.eric.org/types"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema>
<xs:complexType name="quote">
<xs:sequence>
<xs:element name="ID" type="xs:string" minOccurs="0"/>
<xs:element name="time" type="xs:string" minOccurs="0"/>
<xs:element name="val" type="xs:float"/>
</xs:sequence>
</xs:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getStockQuote">
<wsdl:part name="stockTicker" type="xsd:string">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getStockQuoteResponse">
<wsdl:part name="updatedQuote" type="tns:quote">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="quoteReporter">
<wsdl:operation name="getStockQuote">
<wsdl:input name="getQuote" message="tns:getStockQuote">
</wsdl:input>
<wsdl:output name="getQuoteResponse" message="tns:getStockQuoteResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="quoteReporterBinding" type="tns:quoteReporter">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getStockQuote">
<soap:operation style="rpc" />
<wsdl:input name="getQuote">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="getQuoteResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="quoteReporterService">
<wsdl:port name="quoteReporterPort" binding="tns:quoteReporterBinding">
<soap:address location="http://localhost:9000/quoteReporterService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.