LibraryLink ToToggle FramesPrintFeedback

Chapter 3. Developing a Service Using WSDL as a Starting Point

When starting with a WSDL file, ,you need to generate the stub code for your service. You may also need to generate the starting point code for your service. To generate the required code you have two options:

Once the stub code is generated, you can implement your service's logic and deploy it.

If you have a copy of FUSE Services Framework, or Apache CXF, installed on your system, you can use the wsdl2java tool to generate the stub code and the starting point code. Example 3.1 shows the command and the options to use.


The -impl flag tells the tool to generate the starting point code for your implementation. The -d outDir flag tells the tool the name of the folder into which the generated code is written.

For more information about using the FUSE Services Framework tooling see the FUSE Services Framework library..

Even if you do not have FUSE Services Framework or Apache CXF installed, you can generate the required Java classes using the Maven tooling. You need to include the Apache CXF code generation plug-in in your project file and configure it to use the wsdl2java goal.

Example 3.2 shows the XML needed to configure the Apache CXF code generation plug-in to generate the stubs and starting point code.

Example 3.2. Maven Configuration for Generating Starting Point Code From WSDL

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  ...
  <build>
    <plugins>
       ...
       <plugin>
         <groupId>org.apache.cxf</groupId>
         <artifactId>cxf-codegen-plugin</artifactId> 1
         <version>cxf-version</version> 2
         <executions>
            <execution<
              <phase>generate-sources</phase> 3
              <configuration>
                <sourceRoot>sourceDir</sourceRoot> 4
                 <wsdlOptions>
                   <wsdlOption>
                     <wsdl>myService.wsdl</wsdl> 5
                       <extraargs>
                         <extraarg>-impl</extraarg> 6
                       </extraargs>
                   </wsdlOption>
                 </wsdlOptions>
              </configuration>
              <goals>
                <goal>wsdl2java</goal> 7
              </goals>
             </execution>
          </executions>
       </plugin>
      ...
    </plugins>
  </build>
</project>

The Maven POM fragment shown in Example 3.2 does the following:

1

Specifies that the Apache CXF code generation plug-in is to be loaded.

2

Specifies the version of the Apache CXF code generation plug-in to use.

3

Specifies that the plug-in is run during the generate-sources phase of a project build. You evoke the generate-sources phases using the mvn generate-sources command.

4

Specifies the directory into which the generated source files will be placed.

5

Specifies the path to the WSDL file from which the source code will be generated.

6

Specifies that a starting point implementation class is to be generated.

7

Specifies that the code generation plug-in will use its wsdl2java goal.

The implementation code consists of two files:

  • portTypeName.java — The service interface(SEI) for the service.

  • portTypeNameImpl.java — The class you will use to implement the operations defined by the service.

To provide the business logic for your service's operations complete the stub methods in portTypeNameImpl.java. You usually use standard Java to implement the business logic. If your service uses custom XML Schema types, you must use the generated classes for each type to manipulate them. There are also some FUSE Services Framework specific APIs that can be used to access some advanced features.