Generate the server-side code

Next the WSDL is put through the Axis2 tool to generate the server code. This server code contains logic to receive XML from the HTTP server using SOAP (which contains the input data), parse it, and create the types to pass to the main application. It also contains code to turn these types back to XML and return to the Web server, which returns a SOAP response:

  1. In Project Explorer, right-click BookLegacy.wsdl.
  2. Click New > Other.
  3. Expand Web Services, and then click Web Service.
  4. Click Next.
    This opens the Web Service dialog box.
    Note: If the Web service runtime was correctly configured then it displays Apache Axis2. If it does not click on the link it to change it. This opens the Service Deployment Configuration dialog box. Click Apache Axis2, and then click OK.
  5. Click Finish.

    A progress bar might appear while it generates the code.

  6. Once the code is generated the file BookLegacySkeleton.java should appear in an editor pane.
  7. It is a good idea to reformat the source code at this point. Right-click in the editor pane, select Source > Format.

Comments

The classes BookDetails, BookReturn, BookReturnE, NewBook, and StockNo hold instances of the types represented in the WSDL.

In the outline view for BookLegacySkeleton.java are four methods, nextBook(), readBook(), deleteBook(), and addBook(). These are the methods that are called by the web service for the operations that were defined and is where you place your code.

Because you might want to regenerate this code, it is a good idea to keep the user code in this file to a minimum and have all the logic in a separate class. Each of these methods contain one line to invoke an appropriate method in a new class called BookOperation. The next step is to create this class which interfaces between the Web service and the COBOL application.