Monday, November 26, 2012

opentravel web services client test suite


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 properties


This 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 resource directory).

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.
Don Corley
don@tourgeek.com

2 comments:

Sara Soratia said...


In order to remain competitive and efficient in this fierce competition, we need to keep on updating ourselves, especially when you belong to the technology domain. Luckily I have one site called HeatherR or call it BackupPro, which informs and educate about loads of stuff in technology.

Johara Ameena Ganim said...

The information you have provided is exceptional. I was pointed such type of topic since long but lastly nowadays my search is over and special thanks to you. Your blog is not only instructive but useful toofacebook apps developers dubai