Web Services

This schema library contains SOAP and REST services for many of the opentravel message sets. All the hard work is done. All you have to do is implement the service that processes the messages.

For example, this library contains SOAP and REST services that process the opentravel.org Tour Activity messages. You only need to implement the touractivity interface and register your service. The SOAP and REST services will automatically use your implementation. The following example shows you how to do this with the opentravel.org 'ping' service.

For more detailed example, check out my blog here.

Web service example

In this example you will install a simple web service that uses SOAP and REST protocols. This web service implements the opentravel.org ping service. When you send a Ping request this service echos a Ping reply

The service source code for this example is in our repository here.

This example uses three services:

  • Your ping service implementation which is registered as an OSGi service.
  • A ping RESTful service that will call your OSGi registered ping service.
  • A ping SOAP service that also uses your ping service.

Running this example

Step 1: Download Apache karaf and start it up.

 tar zxvf apache-karaf-x.x.x.tar.gz
 cd apache-karaf-x.x.x
 bin/karaf

Step 2: Add and run the JiBX OSGi bundles in this example.

 feature:repo-add mvn:org.apache.cxf.karaf/apache-cxf/3.0.3/xml/features
 feature:install cxf http obr

 obr:addurl http://www.jibx.org/repository.xml
 feature:install cxf-databinding-jibx

 obr:start -d org.jibx.schema.org.opentravel._2012B.ping.ws.service
 obr:start -d org.jibx.schema.org.opentravel._2012B.ping.ws.rest
 obr:start -d org.jibx.schema.org.opentravel._2012B.ping.ws.soap

You just added cxf and a web server to your OSGi container. Then you started a REST and SOAP server and your ping web service.

Step 3: Click this link http://localhost:8092/rest/ping/ping/Hello to send a 'Hello' message to the RESTful ping service.

Load client.html (from the opentravel-ping-service project root directory) into your favorite browser and click 'send'. Most browsers will display the soap xml message returned from the web service (some will just display 'status: 0'). To see the wsdl from karaf, Click here.

Voilà