Monday, November 26, 2012

opentravel web service test suite

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:
Properties properties = new Properties(); properties.setProperty(BaseClient.FILENAME, "/OTA_HotelResRS.xml"); properties.setProperty(BaseClient.CLASSNAME, ResRQ.class.getName()); if (request.getOTAPayloadStdAttributes() != null) if (request.getOTAPayloadStdAttributes().getEchoToken() != null) if (request.getOTAPayloadStdAttributes().getEchoToken().startsWith("/")) properties.setProperty(BaseClient.FILENAME, request.getOTAPayloadStdAttributes().getEchoToken()); response = (ResRS)this.createMessage(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 message class and location (You will find this message in the https://github.com/jibx/schema-library/tree/master/org.opentravel/_2012A/opentravel-ws/opentravel-hotel-ws-test-service/src/main/resources directory). In this test scenario I also have the option to pass the pathname of the the response message in the request message's echotoken attribute.
If you look at the checkpaymentcard method, you can see the power of using java objects to test for xml elements. This would be difficult to do in XPATH or DOM.
public void checkPaymentCard(PaymentCard paymentCard) { if (paymentCard.getSeriesCode() != null) System.out.println("Good - Card info good"); else System.out.println("Error - Card info not good"); }
The utilities in the JiBX web services test suite can be used in the client and service modules. For a description of the other utilities, see my opentravel client test suite blog.
Cheers!
Don Corley
don@tourgeek.com

4 comments:

Steve Smith said...

Great and Useful Article.

Java Web Services Training

Java Web Services Training

John Alert said...

I have read your blog its very attractive and impressive. I like it your blog.


JavaEE Training in Chennai JavaEE Training in Chennai

Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

Java Online Training Java Online Training Core Java 8 Training in Chennai Java 8 Training in Chennai

John Alert said...

Java Web Services Training in Chennai Java Web Services Training in Chennai Java Web Services Online Training Java Web Services Training in Chennai

John Alert said...

JMS Training Institutes in Chennai JMS Training Institutes in Chennai | JSP Training Institutes in Chennai | Spring Training Institutes in Chennai Spring Training Institutes in ChennaiMicroServices Training Institutes In Chennai Java MicroServices Training Institutes In Chennai
Java EE Training Institutes in Chennai Java EE Training Institutes in Chennai