The blueprint.xml file is the configuration file. This blueprint tells the system to register this service to handle opentravel touractivity messages.

The source file handles the actual messages. This code is expected to process request messages and return a response.

If you look at the source code, you will find the method:public AvailRS avail(AvailRQ request)I have included some sample code that returns availability and pricing for several fake tours. This is where you would access your inventory and pricing and populate the return message.The cool part of using a java representation of the opentravel xml message is you can use all the eclipse programming shortcuts, such as auto-complete and documentation display. All the comments and xml snippets from the (complex) opentravel schema have been transferred to the java source code. Try to ctrl-click one of the request or response method names and you will be looking at the java source code model of the xml message.

To build the project, right-click the project name in the project explorer and select Run as -> Maven install

Now we are ready to deploy this code.

For this example, I'll use apache karaf and cxf. You can also use any one of the enhanced esb servers such as Talend or Fuse. In fact, this code uses only open specifications, so you should be able to run it with minor configuration changes on almost any java app server.

Now start the RESTful server and the SOAP server. These servers are configured to send incoming messages to a service registered to handle touractivity messages. (The blueprint.xml file does this) Type these command into the servicemix console.obr:addurl http://www.jibx.org/repository.xmlobr:start -d org.jibx.schema.org.opentravel._2013A.touractivity.ws.soapobr:start -d org.jibx.schema.org.opentravel._2013A.touractivity.ws.rest# Enter the actual group/artifact/version of your project here:start mvn:org.jibx.schema.org.opentravel.ws/org.jibx.schema.org.opentravel._2013A.touractivity.ws.service/0.0.1-SNAPSHOT

Monday, November 26, 2012

If you're a travel industry developer writing an opentravel client for any platform or language, you will need a test web services server as part of your development infrastructure.The open source JiBX project contains tools for web services development, including a complete xml to java binding for the opentravel message schema.When you combine the JiBX tools with an open source web services platform such as servicemix and the tools available for java, you have an excellent platform for testing your opentravel messaging.Let's start with the JiBX web services framework. Click on this link, and follow the directions to set up your web service.If you need help setting up your test environment, take a look at this blog entry for step-by-step instructions on setting up a JiBX maven project in eclipse.Now you're ready to customize your test code. Let's start with the code from our repository.Take a look at this source code. In the res and resmodify method you will see some code like this:

If you're a travel industry developer writing an opentravel service on any platform or language, you will need a test web services client as part of your development infrastructure. Your client will send various messages to your service and then verify that the responses are correct.The open source JiBX project contains tools for web services development, including a complete xml to java binding for the opentravel message schema.When you combine the JiBX tools with all the of tools available for the java platform you have an excellent platform for testing your opentravel messaging.Let's start with the JiBX web services client framework. The client framework is very flexible. It can be used by your client application, or used as a test platform. We'll be running our tests using the maven framework, but you can easily use straight java or run your tests in an OSGi container.Now we're ready to customize our test code. Let's start with the code from our repository at: https://github.com/jibx/schema-library/tree/master/org.opentravel/_2012A/opentravel-ws/opentravel-hotel-ws-test-client. You should download this project and use it as your starting point.Take a look at this source code here. Notice this source code in the start method:

Properties properties = new Properties();properties.setProperty(ENDPOINT, endpoint);properties.setProperty(FILENAME, "/OTA_HotelResRQ.xml");properties.setProperty(CLASSNAME, ResRQ.class.getName());runTest(properties);// By default, run the test once with no propertiesThis code is using the framework's ability to read a local message and marshal it to a Java object. You will see that all that is needed is the java class name and the message location (You will find these xml messages in the project's resourcedirectory).If you prefer unit tests, this project also contains a maven junit test. The source code is here.If you scroll to the bottom of this code, you will see the checkResponseMessage method. You will notice that this method converts the java object to an xml string and prints it. It also converts the message to a DOM tree and does a test. The last line does an XPath test on the xml message.This client code inherits code from the web services Utilities java class. Take a look at this code for the available tools.

This should be everything you need to write a web services client or a web services client test suite.

Friday, November 16, 2012

If you are creating a web services client or server in the Travel Industry, you are probably using the opentravel messaging schema.

Sometimes the most difficult part of your project is creating a test client or server to verify your application code.

soapui is a great open source utility for easily creating manual and automated SOAP test suites.

I'm going to show you how to quickly set up a SOAP test client and a SOAP test server for an opentravel message pair using soapui.

The first thing you will need is a WSDL file. Luckily the ota-tools project has many open source resources for opentravel users, including a soapui project with sample WSDL file that we can use as a template.

You can download this WSDL file from the ota-tools source repository at:

In the dialog box, click the browse button and open the wsdl file that you just edited:

Give your project and name and click 'OK'

Generate a default service

and give it a name:

Now you are ready to start your mock service. Click on the green 'Go' button in the upper left. Now your service is running and you can call it from soapui or the opentravel client that you are developing.

Now let's test our service. Open the sample request and,

press the green 'Go' button in the upper left. You should have a response message on your screen.

Voilà!

Now you are ready to add some logic to your soapui test server and create a soapui client test suite. You will find a nice project with examples in the ota-tools soapui project.

Tuesday, September 18, 2012

This example demonstrates how easy it is to create an Android app that can communicate with travel sites using the opentravel.org message schema.

The JiBX open source project is a java data-binding utility that simplifies handling of xml schema. The JiBX schema library includes pre-built bindings for many message schema, including the complete opentravel schema.

This app uses the 2011B version of the opentravel touractivities search request and reply.

Here is what this app looks like on my phone. Select a date and the available tour activities will display:

Tap on a tour for a detail display:

To illustrate what is happening, let's jump right into the actual source code. I create an opentravel xml touractivity search request and then read through the returned xml reply message.

As you can see, manipulating the xml with java objects instead of xml makes the code easy to understand.

The rest of the code in this application handles the UI and the client calls. It should be familiar to any Android programmer. One of the nice features of Android is the inclusion of many popular open-source libraries, such as the Apache http Client library and the XMLPull parser.

This app is pretty simple. Setting up your development environment is a little tricky.

I prefer maven for my Android development since it automatically includes all the correct opentravel binding modules automatically . You will need to set up maven for Android by following the directions here: http://www.sonatype.com/books/mvnref-book/reference/android-dev.html . Make sure you have deployed android 4.0_r3 into your local maven repo.

Wednesday, April 25, 2012

I'm going to show you how easy it is to write a web service to access a travel product using open source software.

There are two parts to every software project.

First, you have to write the business logic. For example, return the price of a tour on a particular date. This is the fun part.

Second, you have to set up all the extra stuff to make your software work. Web servers, SOAP and REST configuration, etc. This is a pain.

By leveraging open source software, you can minimize the painful part.

For this example we'll assume that you are a local sightseeing company. Your customers want to be able to access real-time pricing and availability for all of our tours.

They use the opentravel 2012A Tour Activity Availability message pair using SOAP over HTTP.

This means you need a web server, a SOAP processing module, and a schema parser, as well as your code. Luckily open source software does most this.

If you're impatient and you just want this demo up and running with a just a few commands, click here for the schema library rest example.

I've created a template for your sample project. To create your project from this template, start eclipse and select:

File -> New -> Project -> Maven Project
On the Archetype screen, select the archetype: opentravel-touractivity-ws-service-archetype. If the artifact doesn't appear, click the 'add archetype' button; GroupId: org.jibx.schema.org.opentravel._2012A.ws, ArtifactId: opentravel-touractivity-ws-service-archetype, Version: 1.0.6 (Not the version show in this image)

On the Project screen, enter your group, artifact name, and version.

You can enter anything you want here. You will need your project group, artifact, and version when you deploy your project.
Click finish to build your project.

This project has two files.

The blueprint.xml file is the configuration file. This blueprint tells the system to register this service to handle opentravel touractivity messages.

The source file handles the actual messages. This code is expected to process request messages and return a response.

If you look at the source code, you will find the method:public AvailRS avail(AvailRQ request)
I have included some sample code that returns availability and pricing for several fake tours. This is where you would access your inventory and pricing and populate the return message.
The cool part of using a java representation of the opentravel xml message is you can use all the eclipse programming shortcuts, such as auto-complete and documentation display. All the comments and xml snippets from the (complex) opentravel schema have been transferred to the java source code. Try to ctrl-click one of the request or response method names and you will be looking at the java source code model of the xml message. Nice!

To build the project, right-click the project name in the project explorer and select Run as -> Maven install

Now we are ready to deploy this code.

For this example, I'll use servicemix. You can also use any one of the enhanced esb servers such as Talend or Fuse. In fact, this code uses only open specifications, so you should be able to run it with minor configuration changes on almost any java app server.

Now start the RESTful server and the SOAP server. These servers are configured to send incoming messages to a service registered to handle touractivity messages. (The blueprint.xml file does this) Type these command into the servicemix console.
features:install obr
obr:addurl http://www.jibx.org/repository.xml
obr:deploy org.jibx.schema.org.opentravel._2012A.touractivity.ws.soap
obr:deploy org.jibx.schema.org.opentravel._2012A.touractivity.ws.rest# Enter the actual group/artifact/version of your project here:
install mvn:org.jibx.schema.org.opentravel.ws/org.jibx.schema.org.opentravel._2012A.touractivity.ws.service/0.0.1-SNAPSHOT
# Note: Due to an OSGi issue, you will need to shutdown and restart servicemix here (ignore any errors on startup):
shutdown
bin/servicemix

Wednesday, December 14, 2011

JiBX is an excellent tool for binding XML data to Java objects on the Android platform.

- JiBX is fast!- JiBX has a small footprint (it will add only 60KB to your .apk)- JiBX uses the Android XMLPull parser by default- It's easy to use!

We all appreciate the advantages of being able to use java classes to do data manipulation. person.setFirstName("Don"); is much easier then messy DOM manipulation: document.getElementsByTagName("first").item(0).appendChild(document.createTextNode("Don"));

This program takes the First and Last Name entered, plugs them into a java data object, marshals the object to xml, and unmarshals the xml back to a data object and extracts the data from it. I made this program very simple, of course you would not do this kind of processing in the main thread.

Run your application by right clicking the project name and selecting 'Debug as' -> 'Android Application'. Enter your first and last name and click the button on the top.