Thursday, January 07, 2010

Creating an OpenTravel Server

Here are step-by-step instructions for setting up a server to process messages from the OpenTravel project.

In this tutorial you will create a module to service the OpenTravel "Ping Request".

Prerequisites:
  1. Download my (tiny) opentravel-webservice framework from the OpenTravel tools project and unzip it. There are several other open source tools in this project that you may want to look at... or contribute to!
  2. Make sure the Java sdk is installed.
  3. Install Apache Maven. This program auto-installs all the build tools and libraries that you will need. Make sure mvn is in your path.
  4. Install a osgi server. I prefer the fuse distribution of Apache Servicemix. Almost all web servers can handle osgi modules, but servicemix has some cool capabilities and tutorials (I based this tutorial on their getting started tutorial).
  5. Install soapui (Optional - If you prefer another web services client, use it). You may have also noticed there is a soaui test framework on the OpenTravel Tools site.
Now you're ready to get started!
  1. Build and Package the webservices modules:
    > cd {your path}/opentravel-webservice
    > mvn install
    (This may take a while the first time you run it. Ignore the warnings)
  2. Install the web service module and the soap interface to your web server:
    > cd {your path}/apache-servicemix-{4.1+ version}
    > bin/servicemix
    karaf@root> features:install cxf-osgi
    (Make sure the apache open source services framework is installed)
    karaf@root> osgi:install -s mvn:org.apache.servicemix.cxf/org.apache.servicemix.cxf.transport.osgi/4.2.0-fuse-SNAPSHOT
    (Install the apache http osgi transport)
    karaf@root> osgi:install -s mvn:org.opentravel/opentravel-webservice-se
    (Install the opentravel web service module that you just built)
    karaf@root> osgi:install -s mvn:org.opentravel/opentravel-webservice-bc
    (Install the opentravel web service soap binding module that you just built)
  3. Test it! Check out the response when I sent this Ping Message using soapui (in a new shell):
    > cd {your path}/soapui
  4. > chmod a+x bin/soapui.sh
  5. (Only do this the first time)
  6. > bin/soapui

  7. File -> New WSDL Project
    The url for your WSDL file is: http://localhost:9090/cxf/openTravelService?WSDL


Now try sending a message. Open the tree openTravelBinding -> PingIncommingRequest -> Request and Paste in this simple ping message:

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://www.opentravel.org/OTA/2003/05">
<soapenv:Header/>
<soapenv:Body>
<ns:OTA_PingRQ Target="Production" Version="1.005">
<ns:EchoData>Hello</ns:EchoData>
</ns:OTA_PingRQ>
</soapenv:Body>
</soapenv:Envelope>

VoilĂ , You've been pinged!





Now you're probably asking yourself if this really creates valid message. Well, let's test it. The ota-tools project has a great test sub-project called ota-soapui. Just open the project in soapui and change the endpoint destination of the four test cases to http://localhost:9090/cxf/openTravelService


Now open the test suite and hit the run button. Cool, all the tests are successful!


This project is a great starting point for your OpenTravel implementation or test project.

Please leave a comment if would like more blogs on this subject... or if you have any questions or recommendations!