Jibx2Wsdl example code

The /examples/jibx2wsdl directory of the JiBX distribution contains some samples for demonstrating the use of Jibx2Wsdl, each in a separate subdirectory. All the samples use the same approach to build a service implementation and corresponding client, starting from a service definition class which implements (or at least defines) some sort of functionality. The service definition class is used to generate a WSDL service definition, and the data classes passed to or from the service methods are used to generate XML schema definitions. This starting code is in a starter directory within each example subdirectory.

If you just want to try generating WSDL and schema definitions (along with the JiBX binding, of course), you can do that using only the JiBX code. If you want to generate and try the client and server code, you also need an Axis2 installation updated with the latest JiBX jars (using the jibx-axis2 download). You may also need to edit the /examples/jibx2wsdl/build.properties file and set the paths to your JiBX and Axis2 (if used) installations. The path provided for JiBX is correct as long as you keep the code as part of your distribution.

All the examples use the same directory structure, with a starter subdirectory for the service definition and data classes, a client directory for the client code, and a server directory for the service code. The client and server directory each contain some provided code to start with, for a simple test program on the client side and for a service implementation class on the server side (which in most cases just delegates to the original service definition class provided in the starter code). The client and server code can only be compiled once the linkage code has been generated using Axis2.

An Ant build.xml file is included in each example. If you run ant from a console open to the example directory, without specifying a target, it'll list the targets available with each example.

Example details

Here's the list of examples:

  • example1 - library service, using books and types with Java 5 typed lists
  • example2 - equivalent to example1, but using arrays rather than Java 5 typed list, and with customizations
  • example3 - more complex library, using polymorphism to include both books and DVDs in the library, using Java 5 typed lists and enums, and customizations
  • example4 - still more complex library, with multiple variations on DVDs, and multiple alternative customizations
  • infoq-example - updated version of code used in the "Code First" Web Services Reconsidered article

Currently only the infoq-example uses any customizations which are specifically for Jibx2Wsdl, rather than just BindGen.