Chapter 4. Migrating a SOAP application to RESTful web services

You can use the WSDL-to-Camel Rest wizard to migrate from an existing JAX-WS SOAP web services implementation to a RESTful web services implementation by using an existing WSDL. The wizard is available as part of Fuse Tooling and it is based on the wsdl2rest utility, available in Github wsdl2rest project.

It supports the following specifications/configurations:

  • Document/literal (doc/lit)
  • Document/literal Wrapped (doc/lit wrap)
  • RPC/literal (rpclit)

4.1. Wizard workflow

The wizard uses a WSDL path which can be a valid URL (in the file:// URL form) or a remote URL (using http or https) and the selected Fuse project. In the wizard, you provide the paths for the generated Java code, the generated Camel configuration file, the target address for the generated camel endpoint, and the bean implementation class.

The wizard generates the destination Java and Camel paths based on the project. The generated Java code is available in src/main/java and the Camel file in an appropriate location for Spring or Blueprint, such as src/main/resources/META-INF/spring.

You can modify the generated classes and configure them to a certain point.

4.2. Prerequisites

Before you begin, you must meet these prerequisites:

  • A pre-existing Fuse Integration Project. You can create a new project using the FileNewFuse Integration Project wizard.
  • A WSDL file accessible through URL. It can be local (file:// url) or remote (http or https).

4.3. Migrating a sample SOAP application to RESTful web services

Follow these steps to run the wizard:

  1. In CodeReady Studio, select your Fuse project in the Project Explorer view.
  2. Right-click on the Fuse project and then select NewCamel Rest DSL from WSDL.

    The Select Incoming WSDL and Project for Generated Output page opens. The Destination Project field is automatically pre-populated with the Fuse project selected in the Project Explorer. This project is the destination for the artifacts that the wizard generates.

    wsdl to rest p1
  3. For WSDL File, specify the original SOAP service for processing.
  4. Click Next. The Specify Advanced Options for WSDL-to-REST Processing page appears.

    wsdl to rest p2
    1. For Destination Java Folder, specify the location of the CXF-generated Java classes.
    2. For Destination Camel Folder, specify the location of the generated Camel Rest DSL configuration file.

      Note

      The path and name of the generated Camel file varies based on the type of Camel project:

      • For Spring projects: src/main/resources/META-INF/rest-camel-context.xml
      • For Spring Boot projects: src/main/resources/spring/rest-springboot-context.xml
      • For Blueprint projects: src/main/resources/OSGI-INF/rest-blueprint-context.xml
    3. Optionally, for Target Service Address provide the SOAP address specified in the WSDL binding. You can change this option to match the actual address of the SOAP service referenced by the WSDL.
    4. Optionally, for Target REST Service Address provide the URL for accessing the REST service. This URL is decomposed into settings for the <restConfiguration> and <rest> tags in the Rest DSL to specify the complete URL for REST operations mapped to the SOAP service.
  5. Click Finish to create two files as the output:

    • The Camel configuration with Rest DSL.
    • Java classes from CXF to wrap the SOAP service.