Tour tech pointers and tutorials. Focused on web services for the travel industry.

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 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.

12 comments:

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.

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

Excellent post!!! Java is most popular and efficient programming language available in the market today. It helps developers to create stunning desktop/web applications loaded with stunning functionalities. J2EE Training in Chennai | JAVA Training in Chennai

The expansion of internet and other business intelligence leads to large volume of data. Industries are looking for talented professionals to maintain and process huge volume of data with latest tools available in the market. Taking Hadoop Training in Chennai | Big Data Training in Chennai will ensure better career prospects for talented professionals.