tag:blogger.com,1999:blog-274586102024-03-03T16:25:48.772-08:00Don's Tour Technology BlogTour tech pointers and tutorials. Focused on web services for the travel industry.Anonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-27458610.post-62714311609894143912013-07-24T14:27:00.000-07:002013-07-24T14:37:02.363-07:00<br />
<h3 class="post-title entry-title" itemprop="name" style="background-color: white; margin: 20px 0px 0px; position: relative;">
<span style="color: black; font-family: Arial, Helvetica, sans-serif; font-size: xx-small; text-decoration: initial;"><a href="http://blog.tourgeek.com/2012/04/creating-soap-and-rest-services-for.html" style="color: black; text-decoration: initial;">opentravel </a>web service - simple example</span></h3>
<div class="post-header" style="background-color: white; line-height: 1.6; margin: 0px 0px 1em;">
<div class="post-header-line-1">
</div>
</div>
<div class="post-body entry-content" id="post-body-2294180955618268782" itemprop="description articleBody" style="background-color: white; line-height: 22px; position: relative; width: 830px;">
<span style="font-family: Arial, Helvetica, sans-serif;">I'm going to show you how easy it is to write a REST and SOAP </span><span style="font-family: Arial, Helvetica, sans-serif;">web service for opentravel messages using open source software.</span></div>
<div class="post-body entry-content" id="post-body-2294180955618268782" itemprop="description articleBody" style="background-color: white; line-height: 22px; position: relative; width: 830px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="post-body entry-content" id="post-body-2294180955618268782" itemprop="description articleBody" style="background-color: white; position: relative; width: 830px;">
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;">By leveraging open source software, most of the difficult code is already written. </span><span style="font-family: Arial, Helvetica, sans-serif;">All you have to do is implement a java </span><span style="font-family: Arial, Helvetica, sans-serif;">interface to service the web service calls.</span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;">You don't have to worry about messy xml handling, you work with java </span><span style="font-family: Arial, Helvetica, sans-serif;">classes. The framework does the work for you.</span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;">For this example we'll assume that you are a local sightseeing company. </span><span style="font-family: Arial, Helvetica, sans-serif;">Your customers want to be able to access real-time pricing and availability </span><span style="font-family: Arial, Helvetica, sans-serif;">for all of our tours.</span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;">They use the opentravel 2013A Tour Activity Availability message pair </span><span style="font-family: Arial, Helvetica, sans-serif;">using SOAP and REST over HTTP.</span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;">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.</span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;">If you're impatient and you just want this demo up and running with a just a few commands, click here for the <a href="http://jibx.sourceforge.net/schema-library/webservices.html" style="color: #436590; text-decoration: initial;">schema library rest example</a>.</span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />I've created a template for your sample project. To create your project from this template, start eclipse and select:</span></div>
<div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />File -> New -> Project -> Maven Project<br />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._2013A.ws, ArtifactId: opentravel-touractivity-ws-service-archetype, Version: 1.1.1 (Not the version show in this image)</span></div>
<div class="separator" style="clear: both; line-height: 22px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5A3cBcXME5Sfz_3SFpONc5NQXR8jFnM_X5qGTV9JCZmLZ1n7hoIjnn96vSrhJ461urwsSzBdJ_tt3b6Pp0QjgtNS1a73voXvNbxgFUuL4AI_bSL8btJKwQdTLfusxdWZLVzDS/s1600/archetype.png" imageanchor="1" style="color: #436590; margin-left: 1em; margin-right: 1em; text-decoration: initial;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" height="148" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5A3cBcXME5Sfz_3SFpONc5NQXR8jFnM_X5qGTV9JCZmLZ1n7hoIjnn96vSrhJ461urwsSzBdJ_tt3b6Pp0QjgtNS1a73voXvNbxgFUuL4AI_bSL8btJKwQdTLfusxdWZLVzDS/s320/archetype.png" style="border: none; position: relative;" width="320" /></span></a></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />On the Project screen, enter your group, artifact name, and version.</span></div>
<div class="separator" style="clear: both; line-height: 22px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGngmJK74XOduuN0BTBpeyF-cbm0XUH1eKsPeQQIjlxFiKUCAQuKlFkwmLk96_7w029BPCFyafByPZFX96krnikeWqE7360O-62_p5b_EjcoJBvlUFf5vnlr6IoDXzWOVLSRlJ/s1600/project.png" imageanchor="1" style="color: #436590; margin-left: 1em; margin-right: 1em; text-decoration: initial;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" height="235" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGngmJK74XOduuN0BTBpeyF-cbm0XUH1eKsPeQQIjlxFiKUCAQuKlFkwmLk96_7w029BPCFyafByPZFX96krnikeWqE7360O-62_p5b_EjcoJBvlUFf5vnlr6IoDXzWOVLSRlJ/s320/project.png" style="border: none; position: relative;" width="320" /></span></a></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />You can enter anything you want here. You will need your project group, artifact, and version when you deploy your project.<br />Click finish to build your project.<br /><br />This project has three files.</span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;">The pom files is the maven project file. You will need to update the parent version number to version 1.1.1. The start of your pom file should look like this:</span></div>
<span style="line-height: 22px;"><span style="font-family: Courier New, Courier, monospace;"> <parent></span></span><br />
<span style="line-height: 22px;"><span style="font-family: Courier New, Courier, monospace;"> <groupid>org.jibx.schema.org.opentravel._2013A.ws</groupid></span></span><br />
<span style="line-height: 22px;"><span style="font-family: Courier New, Courier, monospace;"> <artifactid>opentravel-2013A-ws-reactor</artifactid></span></span><br />
<span style="line-height: 22px;"><span style="font-family: Courier New, Courier, monospace;"> <version>1.1.1</version> </span></span><br />
<span style="line-height: 22px;"><span style="font-family: Courier New, Courier, monospace;"> </parent> </span></span></div>
</div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />The blueprint.xml file is the configuration file. This blueprint tells the system to register this service to handle opentravel touractivity messages.<br /><br />The source file handles the actual messages. This code is expected to process request messages and return a response.<br /><br />If you look at the source code, you will find the method:<br />public AvailRS avail(AvailRQ request)<br />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.<br />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.</span></div>
<div class="separator" style="clear: both; line-height: 22px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0NjaXPBxXzxnwe33rWrgXPqC7_7omx71dxGkWXaoMUCaGwIcpn8eypeoXmBo5bPHczOPE5UBWtYUFfuK5hu0R9t_-2T7TVYqNo8SA2le1XGFdxsI8pQ8x_cVukfNdLmU9LeKP/s1600/source.png" imageanchor="1" style="color: #436590; margin-left: 1em; margin-right: 1em; text-decoration: initial;"><span style="font-family: Arial, Helvetica, sans-serif;"><img border="0" height="78" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0NjaXPBxXzxnwe33rWrgXPqC7_7omx71dxGkWXaoMUCaGwIcpn8eypeoXmBo5bPHczOPE5UBWtYUFfuK5hu0R9t_-2T7TVYqNo8SA2le1XGFdxsI8pQ8x_cVukfNdLmU9LeKP/s320/source.png" style="border: none; position: relative;" width="320" /></span></a></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br />To build the project, right-click the project name in the project explorer and select Run as -> Maven install<br /><br />Now we are ready to deploy this code.<br /><br />For this example, I'll use apache karaf and cxf. You can also use any one of the enhanced esb servers such as <a href="http://www.talend.com/" style="color: #436590; text-decoration: initial;">Talend</a> or <a href="http://fusesource.com/" style="color: #436590; text-decoration: initial;">Fuse</a>. 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.<br /><br />Download <a href="http://karaf.apache.org/">karaf</a>, unzip, and run it:<br /><br /><code>tar zxvf apache-karaf-2.3.2.tar.gz<br />cd apache-karaf-2.3.2<br />bin/karaf</code></span></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;">First, install apache cxf and a few support bundles.</span></div>
<div style="line-height: 22px;">
<code>features:addurl mvn:org.apache.cxf.karaf/apache-cxf/2.7.6/xml/features</code></div>
<div>
<code style="line-height: 22px;">features:install cxf cxf-databinding-jibx http obr</code></div>
<div style="line-height: 22px;">
<span style="font-family: Arial, Helvetica, sans-serif;">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.</span><code><br /></code><span style="font-family: Arial, Helvetica, sans-serif;"><code>obr:addurl http://www.jibx.org/repository.xml<br />obr:start -d org.jibx.schema.org.opentravel._2013A.touractivity.ws.soap<br />obr:start -d org.jibx.schema.org.opentravel._2013A.touractivity.ws.rest</code></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><i># Enter the actual group/artifact/version of your project here:</i><br /><code>start mvn:org.jibx.schema.org.opentravel.ws/org.jibx.schema.org.opentravel._2013A.touractivity.ws.service/0.0.1-SNAPSHOT</code></span><br />
<pre style="padding: 0px;"><i><span style="font-family: Arial, Helvetica, sans-serif;">
</span></i></pre>
<span style="font-family: Arial, Helvetica, sans-serif;">Give it a moment to start, then try out the rest service by clicking this link:<br /><a href="http://localhost:8092/rest/touractivity/avail/cityss/2013-04-12" style="color: #436590; text-decoration: initial;">http://localhost:8092/rest/touractivity/avail/cityss/2013-04-12</a><br /><br />You can test the SOAP service using <a href="http://www.soapui.org/" style="color: #436590; text-decoration: initial;">soapui</a>. The wsdl location is <a href="http://localhost:8092/soap/touractivity?wsdl">http://localhost:8092/soap/touractivity?wsdl</a>.Try sending this soap message:</span><br />
<pre style="padding: 0px;"><span style="font-family: Arial, Helvetica, sans-serif;"><soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"></soapenv:envelope></span><pre style="padding: 0px;"><span style="font-family: Arial, Helvetica, sans-serif;"> <soapenv:header>
<soapenv:body>
<ns:ota_touractivityavailrq target="Production" timestamp="2012-04-19T05:16:51.353Z" version="1.0" xmlns:ns="http://www.opentravel.org/OTA/2003/05/common">
<ns:touractivity>
<ns:basicinfo touractivityid="CITYSS">
<ns:schedule>
<ns:starttime gt="" lt="" ns:starttime="">
</ns:starttime></ns:schedule>
<ns:participantcount quantity="1">
</ns:participantcount></ns:basicinfo></ns:touractivity>
</ns:ota_touractivityavailrq>
</soapenv:body>
</soapenv:header></span></pre>
</pre>
</div>
<span style="font-family: Arial, Helvetica, sans-serif;">
</span>
<br />
<pre style="padding: 0px;"><span style="font-family: Arial, Helvetica, sans-serif;">Your response should look something like this:</span></pre>
<span style="font-family: Arial, Helvetica, sans-serif;">
</span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirLp-Q4qt0Zu6HGjU4wS1SoJ7iNwrnnWjyJm_ulz7Un9dW4Js-_kMcXBm7LvtXBDJknFNTaqoG6ERjLHuzfNaQ-LwYHOpedcyN0QYy_ZMQH6liPf2Npsle-fjF51Tt1F_d3mU6/s1600/soap.png" imageanchor="1" style="color: #436590; margin-left: 1em; margin-right: 1em; text-decoration: initial;"><img border="0" height="159" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirLp-Q4qt0Zu6HGjU4wS1SoJ7iNwrnnWjyJm_ulz7Un9dW4Js-_kMcXBm7LvtXBDJknFNTaqoG6ERjLHuzfNaQ-LwYHOpedcyN0QYy_ZMQH6liPf2Npsle-fjF51Tt1F_d3mU6/s320/soap.png" style="border: none; position: relative;" width="320" /></a></span></div>
<span style="font-family: Arial, Helvetica, sans-serif;">
</span>
<br />
<pre style="padding: 0px;"><span style="font-family: Arial, Helvetica, sans-serif;">Voilà</span></pre>
<div>
<span style="font-family: Times, 'Times New Roman', serif;"><br /></span></div>Anonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.com15tag:blogger.com,1999:blog-27458610.post-91162562774033430692012-11-26T11:16:00.000-08:002012-11-26T11:16:33.546-08:00opentravel web service test suite<span style="font-family: Arial, Helvetica, sans-serif;">If you're a travel industry developer writing an <a href="http://www.opentravel.org/">opentravel</a> client for any platform or language, you will need a test web services server as part of your development infrastructure.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The open source <a href="http://jibx.sourceforge.net/schema-library">JiBX</a> project contains tools for web services development, including a complete xml to java binding for the opentravel message schema.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">When you combine the JiBX tools with an open source web services platform such as <a href="http://servicemix.apache.org/">servicemix</a> and the tools available for java, you have an excellent platform for testing your opentravel messaging.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Let's start with the <a href="http://jibx.sourceforge.net/schema-library/service.html">JiBX web services framework</a>. Click on this link, and follow the directions to set up your web service.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">If you need help setting up your test environment, take a look at this <a href="http://blog.tourgeek.com/2012/04/creating-soap-and-rest-services-for.html">blog entry</a> for step-by-step instructions on setting up a JiBX maven project in eclipse.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Now you're ready to customize your test code. Let's start with the <a href="https://github.com/jibx/schema-library/blob/master/org.opentravel/_2012A/opentravel-ws/opentravel-hotel-ws-test-service/src/main/java/org/jibx/schema/org/opentravel/_2012A/hotel/ws/test/service/HotelServiceImpl.java">code from our repository</a>.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Take a look at this source code. In the res and resmodify method you will see some code like this:</span><br />
<pre style="border: 0px; padding: 0px;"><div class="line" id="LC52" style="border: 0px; color: #333333; line-height: 13.333333015441895px; margin: 0px; padding: 0px 0px 0px 10px;">
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="n" style="border: 0px; margin: 0px; padding: 0px;">Properties</span> <span class="n" style="border: 0px; margin: 0px; padding: 0px;">properties</span> <span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">=</span> <span class="k" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">new</span> <span class="n" style="border: 0px; margin: 0px; padding: 0px;">Properties</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">();
</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">properties</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">setProperty</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">BaseClient</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">FILENAME</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">,</span> <span class="s" style="border: 0px; color: #dd1144; margin: 0px; padding: 0px;">"/OTA_HotelResRS.xml"</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">);
</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">properties</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">setProperty</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">BaseClient</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">CLASSNAME</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">,</span> <span class="n" style="border: 0px; margin: 0px; padding: 0px;">ResRQ</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">class</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">getName</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">());
</span><span class="k" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">if</span> <span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">request</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">getOTAPayloadStdAttributes</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">()</span> <span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">!=</span> <span class="kc" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">null</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">)
</span><span class="k" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;"> if</span> <span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">request</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">getOTAPayloadStdAttributes</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">().</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">getEchoToken</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">()</span> <span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">!=</span> <span class="kc" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">null</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">)
</span><span class="k" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;"> if</span> <span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">request</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">getOTAPayloadStdAttributes</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">().</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">getEchoToken</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">().</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">startsWith</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="s" style="border: 0px; color: #dd1144; margin: 0px; padding: 0px;">"/"</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">))
</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;"> properties</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">setProperty</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">BaseClient</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">FILENAME</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">,</span> <span class="n" style="border: 0px; margin: 0px; padding: 0px;">request</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">getOTAPayloadStdAttributes</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">().</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">getEchoToken</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">());
</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">response</span> <span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">=</span> <span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">ResRS</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">)</span><span class="k" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">this</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">createMessage</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">properties</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">);</span></span></div>
<div style="color: #333333; line-height: 13.333333015441895px;">
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: black; line-height: normal; white-space: normal;">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 </span><a href="https://github.com/jibx/schema-library/tree/master/org.opentravel/_2012A/opentravel-ws/opentravel-hotel-ws-test-service/src/main/resources">https://github.com/jibx/schema-library/tree/master/org.opentravel/_2012A/opentravel-ws/opentravel-hotel-ws-test-service/src/main/resources</a><span style="white-space: normal;"> </span><span style="white-space: normal;">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.</span></span></div>
<div style="color: #333333; line-height: 13.333333015441895px;">
<span style="white-space: normal;"><span style="font-family: Arial, Helvetica, sans-serif;">
</span></span></div>
<div>
<span style="white-space: normal;"><span style="font-family: Arial, Helvetica, sans-serif;">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.</span></span></div>
<div>
<pre style="border: 0px; color: #333333; line-height: 13.333333015441895px; padding: 0px;"><div class="line" id="LC119" style="border: 0px; margin: 0px; padding: 0px 0px 0px 10px;">
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="kd" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">public</span> <span class="kt" style="border: 0px; color: #445588; font-weight: bold; margin: 0px; padding: 0px;">void</span> <span class="nf" style="border: 0px; color: #990000; font-weight: bold; margin: 0px; padding: 0px;">checkPaymentCard</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">PaymentCard</span> <span class="n" style="border: 0px; margin: 0px; padding: 0px;">paymentCard</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">)
</span><span style="font-weight: bold;">{
</span><span class="k" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">if</span> <span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">paymentCard</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">getSeriesCode</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">()</span> <span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">!=</span> <span class="kc" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">null</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">)
</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">System</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">out</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">println</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="s" style="border: 0px; color: #dd1144; margin: 0px; padding: 0px;">"Good - Card info good"</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">);
</span><span style="font-weight: bold;"> else
</span><span class="n" style="border: 0px; margin: 0px; padding: 0px;">System</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">out</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">.</span><span class="na" style="border: 0px; color: teal; margin: 0px; padding: 0px;">println</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">(</span><span class="s" style="border: 0px; color: #dd1144; margin: 0px; padding: 0px;">"Error - Card info not good"</span><span class="o" style="border: 0px; font-weight: bold; margin: 0px; padding: 0px;">);
</span><span style="font-weight: bold;">}</span></span></div>
</pre>
</div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="white-space: normal;">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 </span><a href="http://blog.tourgeek.com/" style="white-space: normal;">opentravel client test suite blog</a><span style="white-space: normal;">.</span></span></div>
<div>
<span style="white-space: normal;"><span style="font-family: Arial, Helvetica, sans-serif;">
</span></span></div>
<div>
<span style="white-space: normal;"><span style="font-family: Arial, Helvetica, sans-serif;">Cheers!</span></span></div>
<div>
<span style="white-space: normal;"><span style="font-family: Arial, Helvetica, sans-serif;">
</span></span></div>
<div>
<span style="white-space: normal;"><span style="font-family: Arial, Helvetica, sans-serif;">Don Corley</span></span></div>
<div>
<span style="white-space: normal;"><span style="font-family: Arial, Helvetica, sans-serif;">don@tourgeek.com</span></span></div>
</pre>
Anonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.com6tag:blogger.com,1999:blog-27458610.post-75325521181760979672012-11-26T11:15:00.000-08:002012-11-26T11:15:38.515-08:00opentravel web services client test suite<br />
<span style="font-family: Arial, Helvetica, sans-serif;">If you're a travel industry developer writing an <a href="http://www.opentravel.org/">opentravel</a> 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.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">The open source <a href="http://jibx.sourceforge.net/schema-library">JiBX</a> project contains tools for web services development, including a complete xml to java binding for the opentravel message schema.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">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.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Let's start with the <a href="http://jibx.sourceforge.net/schema-library/client.html">JiBX web services client framework</a>. 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 <a href="http://maven.apache.org/">maven</a> framework, but you can easily use straight java or run your tests in an OSGi container.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Now we're ready to customize our test code. Let's start with the code from our repository at: <a href="https://github.com/jibx/schema-library/tree/master/org.opentravel/_2012A/opentravel-ws/opentravel-hotel-ws-test-client">https://github.com/jibx/schema-library/tree/master/org.opentravel/_2012A/opentravel-ws/opentravel-hotel-ws-test-client</a>. You should download this project and use it as your starting point.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Take a look at this <a href="https://github.com/jibx/schema-library/blob/master/org.opentravel/_2012A/opentravel-ws/opentravel-hotel-ws-test-client/src/main/java/org/jibx/schema/org/opentravel/_2012A/hotel/ws/test/client/HotelClientTest.java">source code here</a>. Notice this source code in the start method:</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">Properties properties = new Properties();<br />properties.setProperty(ENDPOINT, endpoint);<br />properties.setProperty(FILENAME, "/OTA_HotelResRQ.xml");<br />properties.setProperty(CLASSNAME, ResRQ.class.getName());<br />runTest(properties);<span class="Apple-tab-span" style="white-space: pre;"> </span>// By default, run the test once with no properties</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">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 </span><a href="https://github.com/jibx/schema-library/tree/master/org.opentravel/_2012A/opentravel-ws/opentravel-hotel-ws-test-client/src/main/resources" style="font-family: Arial, Helvetica, sans-serif;">resource</a><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 13.333333015441895px;"> </span><span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 13.333333015441895px;">directory).</span><br />
<span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 13.333333015441895px;"><br /></span>
<span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 13.333333015441895px;">If you prefer unit tests, this project also contains a maven junit test. The <a href="https://github.com/jibx/schema-library/blob/master/org.opentravel/_2012A/opentravel-ws/opentravel-hotel-ws-test-client/src/test/java/org/jibx/schema/org/opentravel/_2012A/hotel/ws/test/client/HotelClientTestCase.java">source code is here</a>.</span><br />
<span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 13.333333015441895px;"><br /></span>
<span style="color: #333333; font-family: Arial, Helvetica, sans-serif; line-height: 13.333333015441895px;">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.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">This client code inherits code from the </span><a href="https://github.com/jibx/schema-library/blob/master/schema-utilities/jibx-ws-utilities/src/main/java/org/jibx/schema/ws/utilities/Utilities.java" style="font-family: Arial, Helvetica, sans-serif;">web services Utilities</a><span style="font-family: Arial, Helvetica, sans-serif;"> java class. Take a look at this code for the available tools.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<br />
<pre style="border: 0px; padding: 0px;"><div>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="white-space: normal;">This should be everything you need to write a web services client or a web services client test suite.</span></span></div>
<div>
<span style="white-space: normal;"><span style="font-family: Arial, Helvetica, sans-serif;">Don Corley</span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif; white-space: normal;">don@tourgeek.com</span></div>
</pre>
Anonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.com16tag:blogger.com,1999:blog-27458610.post-43827405262120273442012-11-16T07:56:00.001-08:002012-11-26T07:22:41.842-08:00Creating an opentravel SOAP client and server for testing using soapuiIf you are creating a web services client or server in the Travel Industry, you are probably using the <a href="http://www.opentravel.org/">opentravel</a> messaging schema.<br />
<div>
<br /></div>
<div>
Sometimes the most difficult part of your project is creating a test client or server to verify your application code.</div>
<div>
<br /></div>
<div>
<a href="http://www.soapui.org/">soapui</a> is a great open source utility for easily creating manual and automated SOAP test suites.</div>
<div>
<br /></div>
<div>
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.</div>
<div>
<br /></div>
<div>
The first thing you will need is a WSDL file. Luckily the <a href="http://ota-tools.sourceforge.net/">ota-tools</a> project has many open source resources for opentravel users, including a <a href="http://ota-tools.sourceforge.net/ota-soapui/index.html">soapui project</a> with sample WSDL file that we can use as a template.</div>
<div>
<br /></div>
<div>
You can download this WSDL file from the ota-tools source repository at:</div>
<div>
<a href="https://sourceforge.net/p/ota-tools/code/ci/f0311dbe474aa80f7f12bcbed27695ac7b22675f/tree/java/ota-soapui/opentravel.wsdl">https://sourceforge.net/p/ota-tools/code/ci/f0311dbe474aa80f7f12bcbed27695ac7b22675f/tree/java/ota-soapui/opentravel.wsdl</a></div>
<div>
<br /></div>
<div>
This WSDL is currently configured for the 2012A version of the Ping message pair. If you would like to use a different message pair, just change the import statements to point to your root schema.</div>
<div>
<br /></div>
<div>
For example, if I want to test the cancellation message pair, I would change:</div>
<div>
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><xsd:import namespace="http://www.opentravel.org/OTA/2003/05"</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> schemaLocation="http://www.opentravel.org/2012A/<span style="background-color: #ea9999;">OTA_PingRQ</span>.xsd" /></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><xsd:import namespace="http://www.opentravel.org/OTA/2003/05"</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> schemaLocation="http://www.opentravel.org/2012A/<span style="background-color: #ea9999;">OTA_PingRS</span>.xsd" /></span></div>
<div>
<b>to:</b></div>
<div>
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><xsd:import namespace="http://www.opentravel.org/OTA/2003/05"</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> schemaLocation="http://www.opentravel.org/2012A/<span style="background-color: yellow;">OTA_CancelRQ.xsd</span>" /></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><xsd:import namespace="http://www.opentravel.org/OTA/2003/05"</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> schemaLocation="http://www.opentravel.org/2012A/<span style="background-color: yellow;">OTA_CancelRS.xsd</span>" /></span></div>
<div>
<br /></div>
<div>
Then change the message root elements to match the root elements of the schema that you are testing. In this example, I would change:</div>
<div>
<br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"><</span><span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">wsdl:message name="Request"></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span><wsdl:part element="ota:<span style="background-color: #ea9999;">OTA_PingRQ</span>" name="payload"></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></wsdl:part></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"></wsdl:message></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><wsdl:message name="Response"></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span><wsdl:part element="ota:<span style="background-color: #ea9999;">OTA_PingRS</span>" name="payload"></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></wsdl:part></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"></wsdl:message></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"></span></div>
<div>
<b>to:</b></div>
<div>
<br />
<span style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"><</span><span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">wsdl:message name="Request"></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span><wsdl:part element="ota:<span style="background-color: yellow;">OTA_CancelRQ</span>" name="payload"></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></wsdl:part></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"></wsdl:message></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><wsdl:message name="Response"></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span><wsdl:part element="ota:<span style="background-color: yellow;">OTA_CancelRS</span>" name="payload"></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span></wsdl:part></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"></wsdl:message></span><br />
<div>
<br /></div>
</div>
<div>
Now you are ready to create a test client and server in soapui.</div>
<div>
<br /></div>
<div>
From the soapui main menu, select, File -> New soapui Project</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDSr9PAnG2fAvW4jxNSS1eROw2cxyfwbHY6B8b4GFaeRnq_Wa49AJKU2zuuS7HjaAQY7JW04rCQcZ9s3IwXamuUc7ZfUyREHhrA46pdfPvIoezZVckW5mnWgfA57umw4e-Q-l5/s1600/01-open.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="87" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDSr9PAnG2fAvW4jxNSS1eROw2cxyfwbHY6B8b4GFaeRnq_Wa49AJKU2zuuS7HjaAQY7JW04rCQcZ9s3IwXamuUc7ZfUyREHhrA46pdfPvIoezZVckW5mnWgfA57umw4e-Q-l5/s320/01-open.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
In the dialog box, click the browse button and open the wsdl file that you just edited:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3Vy69h7Nt4ZIaV8d6btPwi8ikn3L-4-iuJlPV8mPWkghM3I6dD4xyRJzXRJmLG1bl322mth3v-BnOOYkiVPXGG6cF7tkZDwP-F674o6PVLpO74l_TM-ctd43YShFrNWWPyqaM/s1600/02-select.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="226" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3Vy69h7Nt4ZIaV8d6btPwi8ikn3L-4-iuJlPV8mPWkghM3I6dD4xyRJzXRJmLG1bl322mth3v-BnOOYkiVPXGG6cF7tkZDwP-F674o6PVLpO74l_TM-ctd43YShFrNWWPyqaM/s320/02-select.png" width="320" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
</div>
<div class="separator" style="clear: both;">
Give your project and name and click 'OK'</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuS_RbOTs96FFa5QurIbfZ1jWBCZeTKdXOFWvctT-LpKNrUYFXFBvbnh6h4DHNspJsnxkw9gBUcQsTnELZyU19Bi5SQEo15ZhLiIdRrBhozTMabniL5S0RZE6qF0An2zmU9K0v/s1600/03-select.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="159" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuS_RbOTs96FFa5QurIbfZ1jWBCZeTKdXOFWvctT-LpKNrUYFXFBvbnh6h4DHNspJsnxkw9gBUcQsTnELZyU19Bi5SQEo15ZhLiIdRrBhozTMabniL5S0RZE6qF0An2zmU9K0v/s320/03-select.png" width="320" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
</div>
<div class="separator" style="clear: both;">
Generate a default service</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkwgxtOEupKnyzfS2mrmk1ZK53VXnAw3YbxLYnVPI4nfMYzHcglc8UZdvY3eBpAjI_Oz3-On288fKlCeQymBiPz_gz5JCTshMradpHgKbQw4l76w8x-zEPv600oUOukWFqOx-N/s1600/04-service.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkwgxtOEupKnyzfS2mrmk1ZK53VXnAw3YbxLYnVPI4nfMYzHcglc8UZdvY3eBpAjI_Oz3-On288fKlCeQymBiPz_gz5JCTshMradpHgKbQw4l76w8x-zEPv600oUOukWFqOx-N/s320/04-service.png" width="320" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
</div>
<div class="separator" style="clear: both;">
and give it a name:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTr0972DmM1xxxtwJAqRNiQIkglWHR4cm67mIsdG7ZIpu7ATN6WVg_BdrrvstFZ0L4p8VOWbz_lZ8AGPKILiLKfMk_KjHH1-VFzbXVbA5Bm8MMfDVBrOE9ASqvmEJotiwo4VsX/s1600/05-name.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="127" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTr0972DmM1xxxtwJAqRNiQIkglWHR4cm67mIsdG7ZIpu7ATN6WVg_BdrrvstFZ0L4p8VOWbz_lZ8AGPKILiLKfMk_KjHH1-VFzbXVbA5Bm8MMfDVBrOE9ASqvmEJotiwo4VsX/s320/05-name.png" width="320" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
</div>
<div class="separator" style="clear: both;">
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.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIQLoBv-9y_AqYXteIe17mluqBla7WugGsEOosu8pcrz_El479ki6Zm-opiPACdOm3YInWq5cBsHtHYH4PfS8wMjPjtpYyuASpZ0zR67gmSOwNAX6VVqmvqdtRfCfVErHlgfMP/s1600/06-start.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="115" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIQLoBv-9y_AqYXteIe17mluqBla7WugGsEOosu8pcrz_El479ki6Zm-opiPACdOm3YInWq5cBsHtHYH4PfS8wMjPjtpYyuASpZ0zR67gmSOwNAX6VVqmvqdtRfCfVErHlgfMP/s320/06-start.png" width="320" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
</div>
<div class="separator" style="clear: both;">
Now let's test our service. Open the sample request and,</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUxJZXMgWfXhnZ3mD34n6JuKzBbTO4gWoJwj-3lJHww1JZcYSI7uhXzydFdMSiQmzkB2JteY4gNbDnK5P-YLF0HHf3oQqv6PAGicTyj9MsKPGPjXtdLWg4ml2-e_GGhGTLp4aP/s1600/07-request.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="96" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUxJZXMgWfXhnZ3mD34n6JuKzBbTO4gWoJwj-3lJHww1JZcYSI7uhXzydFdMSiQmzkB2JteY4gNbDnK5P-YLF0HHf3oQqv6PAGicTyj9MsKPGPjXtdLWg4ml2-e_GGhGTLp4aP/s320/07-request.png" width="320" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
</div>
<div class="separator" style="clear: both;">
press the green 'Go' button in the upper left. You should have a response message on your screen.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2kKMTsVc17SMXmd2boXaLjB-k9hHbc9EVzEhyphenhyphentX4kkYTLSe41O1TvLlDhaFNkyN-pQI-Qmkq_xgPMrcCbkKjpz1RCxGg7jfcJr0gl98325gbJAxcJxFxjVrEBHl0wxuzOMsm9/s1600/08-response.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="265" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2kKMTsVc17SMXmd2boXaLjB-k9hHbc9EVzEhyphenhyphentX4kkYTLSe41O1TvLlDhaFNkyN-pQI-Qmkq_xgPMrcCbkKjpz1RCxGg7jfcJr0gl98325gbJAxcJxFxjVrEBHl0wxuzOMsm9/s320/08-response.png" width="320" /></a></div>
<div class="separator" style="clear: both;">
<i> <b>Voilà!</b></i></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
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 <a href="http://ota-tools.sourceforge.net/ota-soapui/index.html">ota-tools soapui</a> project.</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
This sample project is located in our source repository at:</div>
<div class="separator" style="clear: both;">
<a href="https://sourceforge.net/p/ota-tools/code/ci/f0311dbe474aa80f7f12bcbed27695ac7b22675f/tree/java/ota-soapui/">https://sourceforge.net/p/ota-tools/code/ci/f0311dbe474aa80f7f12bcbed27695ac7b22675f/tree/java/ota-soapui/</a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Just download the opentravel-soapui-project.xml file and import it into soapui.</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Now you're ready to test your opentravel client or server code!</div>
<br />
<br />
<br />
<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.com7tag:blogger.com,1999:blog-27458610.post-84408600405596970412012-09-18T01:39:00.001-07:002012-09-18T01:39:36.816-07:00Opentravel Mobile Android App development with the JiBX open source frameworkThis example demonstrates how easy it is to create an Android app that can communicate with travel sites using the opentravel.org message schema.<br />
<br />
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.<br />
<br />
This app uses the 2011B version of the opentravel touractivities search request and reply.<br />
<br />
Here is what this app looks like on my phone. Select a date and the available tour activities will display:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS-n1NYXIUHK9DAQckrvZD2p9CGr6294pVnsJkJqfWaZOd_x3dxbd8-HSEBfYCNo7htoXWqPfntE5BQXbBKfGTVQ7nbxrXzVgOdU6PsKFzYfNP-xSizjLreZV4fiyI6b7gKWeX/s1600/Screenshot_2012-09-17-23-52-20.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhS-n1NYXIUHK9DAQckrvZD2p9CGr6294pVnsJkJqfWaZOd_x3dxbd8-HSEBfYCNo7htoXWqPfntE5BQXbBKfGTVQ7nbxrXzVgOdU6PsKFzYfNP-xSizjLreZV4fiyI6b7gKWeX/s400/Screenshot_2012-09-17-23-52-20.png" width="225" /></a></div>
Tap on a tour for a detail display:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9wLskk-fcmSYKb9gs3eQLfA3neZry3ia7L6nDBR8uDjfmLo4Pjt3TI3lfGvU6FByA9yBg4_AJdc0jdJ7L9ebksYYK4F55neXUVlwDfgtRBv9FQtbCiH_6tRGoWVkXGb1wuKay/s1600/Screenshot_2012-09-17-23-51-54.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="166" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9wLskk-fcmSYKb9gs3eQLfA3neZry3ia7L6nDBR8uDjfmLo4Pjt3TI3lfGvU6FByA9yBg4_AJdc0jdJ7L9ebksYYK4F55neXUVlwDfgtRBv9FQtbCiH_6tRGoWVkXGb1wuKay/s200/Screenshot_2012-09-17-23-51-54.png" width="200" /></a></div>
<br />
<br />
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.<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">// Populate the search request</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">SearchRQ searchRQ = new SearchRQ();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">OTAPayloadStdAttributes payload = BaseService.createStandardPayload();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">searchRQ.setOTAPayloadStdAttributes(payload);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">DateTimePref dateTimePref = new DateTimePref();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">searchRQ.setDateTimePref(dateTimePref);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">dateTimePref.setStart(YMDdate);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">dateTimePref.setEnd(YMDdate);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">// Send it to the server and get the result</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">SearchRS searchRS = search(searchRQ);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">if (searchRS == null)</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return null;</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">// Extract the information from the results</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">List<tourinfo> tourProducts = new Vector<tourinfo>();</tourinfo></tourinfo></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">List<touractivityinfo> tourActivities = searchRS.getTourActivityInfoList();</touractivityinfo></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">if ((tourActivities == null) || (searchRS.getErrors() != null))</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return getErrorMessage(searchRS);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">for (TourActivityInfo tourActivityInfo : tourActivities)</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">{</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>TourInfo tourInfo = new TourInfo();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>TourActivityID tourActivityID = tourActivityInfo.getBasicInfo();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>tourInfo.tourID = tourActivityID.getTourActivityID();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>TourActivityDescription tourActivityDescription = tourActivityInfo.getDescription();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if (tourActivityDescription != null)</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>tourInfo.description = tourActivityDescription.getShortDescription();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Pricing pricing = tourActivityInfo.getPricing();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if (pricing != null)</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>tourInfo.minPrice = pricing.getMinPrice();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>tourInfo.maxPrice = pricing.getMaxPrice();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>tourProducts.add(tourInfo);</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">}</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">// Return the tours to display</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: xx-small;">return tourProducts;</span><br />
<div>
<br /></div>
As you can see, manipulating the xml with java objects instead of xml makes the code easy to understand.<br />
<br />
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.<br />
<br />
This app is pretty simple. Setting up your development environment is a little tricky.<br />
<br />
First, you will need a server that is set up to service your requests. Just follow the steps in my post here: <a href="http://blog.tourgeek.com/2012/04/creating-soap-and-rest-services-for.html">http://blog.tourgeek.com/2012/04/creating-soap-and-rest-services-for.html</a> . Make sure the server is working by pointing a browser to the server with this url (just replace this IP address with your server's IP): <a href="http://192.168.1.100:8181/cxf/touractivity/search/2012-09-04/2012-09-04">http://192.168.1.100:8181/cxf/touractivity/search/2012-09-04/2012-09-04</a> . You should get an XML reply message. Our app will be (html) posting a RESTful XML request rather than using url parameters.<br />
<br />
Now we're ready to create our Android application.<br />
<br />
Check out this example from github: <a href="https://github.com/jibx/schema-library/tree/master/schema-utilities/examples/android/org.jibx.android.demo.touractivity">https://github.com/jibx/schema-library/tree/master/schema-utilities/examples/android/org.jibx.android.demo.touractivity</a><br />
<br />
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: <a href="http://www.sonatype.com/books/mvnref-book/reference/android-dev.html">http://www.sonatype.com/books/mvnref-book/reference/android-dev.html</a> . Make sure you have deployed android 4.0_r3 into your local maven repo.<br />
<br />
To build the code, just type:<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">mvn clean install</span><br />
<br />
Now install your .apk file (from the maven target directory) onto your Android device.<br />
<br />
Once you run the app, click the menu button to change the settings. Enter the IP address of your server and click okay:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYhIgb9V4La8oqYal_fFASHew3yDmwRcSLqX2A-f2JKHpmgoTI5EwlAKS7StnanvoiFAz-o5Ty2eXuk4c-qALD_YzeNPzXsQSdGrN3bE1Fa6nxJGoGc2cK1rA6iMtF6izVxh6T/s1600/Screenshot_2012-09-17-23-52-44.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="222" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYhIgb9V4La8oqYal_fFASHew3yDmwRcSLqX2A-f2JKHpmgoTI5EwlAKS7StnanvoiFAz-o5Ty2eXuk4c-qALD_YzeNPzXsQSdGrN3bE1Fa6nxJGoGc2cK1rA6iMtF6izVxh6T/s320/Screenshot_2012-09-17-23-52-44.png" width="320" /></a></div>
You should see the tour display. Try changing the date to update the tour display (Some of the tours do not run on Tuesdays).<br />
<br />
<i>Voilà!</i><br />
<br />
Take a look at the source code. You'll be amazed at how simple it is.<br />
<br />
I hope this example helps you create your own app using the opentravel schema. If you have questions, contact me at don@tourgeek.com or place a comment in the space below.<br />
<br />
DonAnonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.com166tag:blogger.com,1999:blog-27458610.post-22941809556182687822012-04-25T13:50:00.002-07:002012-09-04T21:17:29.984-07:00Creating SOAP and REST services for opentravel messagesI'm going to show you how easy it is to write a web service to access a travel product using open source software.<br />
<div>
<br /></div>
<div>
There are two parts to every software project.</div>
<div>
<br /></div>
<div>
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.</div>
<div>
<br /></div>
<div>
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.<br />
<br />
By leveraging open source software, you can minimize the painful part.</div>
<div>
<br /></div>
<div>
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.</div>
<div>
<br /></div>
<div>
They use the opentravel 2012A Tour Activity Availability message pair using SOAP over HTTP.</div>
<div>
<br /></div>
<div>
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.</div>
<div>
<br /></div>
<div>
If you're impatient and you just want this demo up and running with a just a few commands, click here for the <a href="http://jibx.sourceforge.net/schema-library/webservices.html">schema library rest example</a>.</div>
<div>
<br />
I've created a template for your sample project. To create your project from this template, start eclipse and select:</div>
<div>
<br />
File -> New -> Project -> Maven Project<br />
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)<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5A3cBcXME5Sfz_3SFpONc5NQXR8jFnM_X5qGTV9JCZmLZ1n7hoIjnn96vSrhJ461urwsSzBdJ_tt3b6Pp0QjgtNS1a73voXvNbxgFUuL4AI_bSL8btJKwQdTLfusxdWZLVzDS/s1600/archetype.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="148" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5A3cBcXME5Sfz_3SFpONc5NQXR8jFnM_X5qGTV9JCZmLZ1n7hoIjnn96vSrhJ461urwsSzBdJ_tt3b6Pp0QjgtNS1a73voXvNbxgFUuL4AI_bSL8btJKwQdTLfusxdWZLVzDS/s320/archetype.png" width="320" /></a></div>
<br />
On the Project screen, enter your group, artifact name, and version.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGngmJK74XOduuN0BTBpeyF-cbm0XUH1eKsPeQQIjlxFiKUCAQuKlFkwmLk96_7w029BPCFyafByPZFX96krnikeWqE7360O-62_p5b_EjcoJBvlUFf5vnlr6IoDXzWOVLSRlJ/s1600/project.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="235" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGngmJK74XOduuN0BTBpeyF-cbm0XUH1eKsPeQQIjlxFiKUCAQuKlFkwmLk96_7w029BPCFyafByPZFX96krnikeWqE7360O-62_p5b_EjcoJBvlUFf5vnlr6IoDXzWOVLSRlJ/s320/project.png" width="320" /></a></div>
<br />
You can enter anything you want here. You will need your project group, artifact, and version when you deploy your project.<br />
Click finish to build your project.<br />
<br />
This project has two files.<br />
<br />
The blueprint.xml file is the configuration file. This blueprint tells the system to register this service to handle opentravel touractivity messages.<br />
<br />
The source file handles the actual messages. This code is expected to process request messages and return a response.<br />
<br />
If you look at the source code, you will find the method:<br />
<span style="font-family: 'Courier New', Courier, monospace;">public AvailRS avail(AvailRQ request)</span><br />
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.<br />
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!<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0NjaXPBxXzxnwe33rWrgXPqC7_7omx71dxGkWXaoMUCaGwIcpn8eypeoXmBo5bPHczOPE5UBWtYUFfuK5hu0R9t_-2T7TVYqNo8SA2le1XGFdxsI8pQ8x_cVukfNdLmU9LeKP/s1600/source.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="78" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0NjaXPBxXzxnwe33rWrgXPqC7_7omx71dxGkWXaoMUCaGwIcpn8eypeoXmBo5bPHczOPE5UBWtYUFfuK5hu0R9t_-2T7TVYqNo8SA2le1XGFdxsI8pQ8x_cVukfNdLmU9LeKP/s320/source.png" width="320" /></a></div>
<br />
To build the project, right-click the project name in the project explorer and select Run as -> Maven install<br />
<br />
Now we are ready to deploy this code.<br />
<br />
For this example, I'll use servicemix. You can also use any one of the enhanced esb servers such as <a href="http://www.talend.com/">Talend</a> or <a href="http://fusesource.com/">Fuse</a>. 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.<br />
<br />
Download servicemix, unzip, and run it:<br />
<br />
<code>
tar zxvf apache-servicemix-4.4.2.tar.gz<br />
cd apache-servicemix-4.4.2<br />
bin/servicemix<br />
</code>
<br />
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.<br />
<code>
features:install obr<br />
obr:addurl http://www.jibx.org/repository.xml<br />
obr:deploy org.jibx.schema.org.opentravel._2012A.touractivity.ws.soap<br />
obr:deploy org.jibx.schema.org.opentravel._2012A.touractivity.ws.rest<br />
</code>
<span style="font-family: Times, 'Times New Roman', serif;"><i># Enter the actual group/artifact/version of your project here:</i></span><br />
<code>
install mvn:org.jibx.schema.org.opentravel.ws/org.jibx.schema.org.opentravel._2012A.touractivity.ws.service/0.0.1-SNAPSHOT<br />
</code>
<span style="font-family: Times, 'Times New Roman', serif;"><i>
# Note: Due to an OSGi issue, you will need to shutdown and restart servicemix here (ignore any errors on startup):</i></span><br />
<code>
shutdown<br />
bin/servicemix
</code>
<br />
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: Times, 'Times New Roman', serif;"><i>
# After it starts back up, start your services:</i></span></pre>
<code>
start org.jibx.schema.org.opentravel._2012A.touractivity.ws.service<br />
start org.jibx.schema.org.opentravel._2012A.touractivity.ws.soap<br />
start org.jibx.schema.org.opentravel._2012A.touractivity.ws.rest<br />
</code>
<br />
Give it a moment to start, then try out the rest service by clicking this link:<br />
<a href="http://localhost:8181/cxf/touractivity/avail/cityss/2012-04-12">http://localhost:8181/cxf/touractivity/avail/cityss/2012-04-12</a><br />
<br />
You can test the SOAP service using <a href="http://www.soapui.org/">soapui</a>. The wsdl location is http://localhost:8092/soap/touractivity?wsdl.Try sending this soap message:<br />
<br />
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"> <soapenv:Header/>
<soapenv:Body>
<ns:OTA_TourActivityAvailRQ TimeStamp="2012-04-19T05:16:51.353Z" Target="Production" Version="1.0"
xmlns:ns="http://www.opentravel.org/OTA/2003/05">
<ns:TourActivity>
<ns:BasicInfo TourActivityID="CITYSS"/>
<ns:Schedule>
<ns:StartTime>2012-05-11</ns:StartTime>
</ns:Schedule>
<ns:ParticipantCount Quantity="1"/>
</ns:TourActivity>
</ns:OTA_TourActivityAvailRQ>
</soapenv:Body>
</soapenv:Envelope></pre>
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: Times, 'Times New Roman', serif;">Your response should look something like this:</span></pre>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirLp-Q4qt0Zu6HGjU4wS1SoJ7iNwrnnWjyJm_ulz7Un9dW4Js-_kMcXBm7LvtXBDJknFNTaqoG6ERjLHuzfNaQ-LwYHOpedcyN0QYy_ZMQH6liPf2Npsle-fjF51Tt1F_d3mU6/s1600/soap.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="159" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirLp-Q4qt0Zu6HGjU4wS1SoJ7iNwrnnWjyJm_ulz7Un9dW4Js-_kMcXBm7LvtXBDJknFNTaqoG6ERjLHuzfNaQ-LwYHOpedcyN0QYy_ZMQH6liPf2Npsle-fjF51Tt1F_d3mU6/s320/soap.png" width="320" /></a></div>
<pre style="padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"><span style="font-family: Times, 'Times New Roman', serif;">Voilà</span></pre>
</pre>
<br /></div>
Anonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.com9tag:blogger.com,1999:blog-27458610.post-13739624450008318022011-12-14T08:19:00.001-08:002011-12-14T16:40:02.835-08:00XML Data Binding for Java on Android using JiBX<a href="http://www.jibx.org/">JiBX</a> is an excellent tool for binding XML data to Java objects on the Android platform.<br /><br />- JiBX is fast!<br />- JiBX has a small footprint (it will add only 60KB to your .apk)<br />- JiBX uses the Android XMLPull parser by default<br />- It's easy to use!<br /><br />We all appreciate the advantages of being able to use java classes to do data manipulation. <code>person.setFirstName("Don"); </code>is much easier then messy <i>DOM </i>manipulation: <code>document.getElementsByTagName("first").item(0).appendChild(document.createTextNode("Don"));</code><div><br />Let's create a sample project.<div><br />First, create java bindings for your XML schema using <a href="http://jibx.org/">JiBX</a>, or select a pre-build schema library.</div><div><br />For this example, we'll use a pre-built binding from the <a href="http://www.jibx.org/schema-library">JiBX schema library</a>. Our sample xsd file is an XML definition which includes a person's first and last name.<br /><br />Click <a href="http://jibx.sourceforge.net/schema-library/site.html#Schema_Library_-_jibx.org_-_Person_Schema">here to see our sample schema in the JiBX library</a>. You may want to take a look at the schema and the JiBX generated java source code.<br /><br />Download the java jar file by right-clicking this<br /><a href="http://repo2.maven.org/maven2/org/jibx/schema/org/jibx/org.jibx.schema.org.jibx.sampleschema.person/1.0.0/org.jibx.schema.org.jibx.sampleschema.person-1.0.0.jar">link</a> and select 'save as'.<br /><br />Next, download the jibx runtime jar file by right-clicking this <a href="http://repo2.maven.org/maven2/org/jibx/jibx-run/1.2.3/jibx-run-1.2.3.jar">link</a> and select 'save as'. We'll need these jars shortly.<br /><br />Now we're ready to create our Android application. First you need to install <a href="http://www.eclipse.org/">eclipse</a> and the <a href="http://developer.android.com/sdk/index.html">Android SDK</a>.<br /><br />From Eclipse, select New -> Project -> Android Project.<br /><br />I'm calling this project 'jibxapp'.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif_9A4XIIfN171e-_JW_9zaI221fZuL4QCgmZZNPa0lIohYAkXNnurFV2kdF88Zl4sR6F2y9Jkus7QhfgY4d9WsSoMKMWaiZ_e757Kxk2hZe3zC8LF0-fjqA7klG6TVp9W8RNo/s1600/01-project.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 81px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif_9A4XIIfN171e-_JW_9zaI221fZuL4QCgmZZNPa0lIohYAkXNnurFV2kdF88Zl4sR6F2y9Jkus7QhfgY4d9WsSoMKMWaiZ_e757Kxk2hZe3zC8LF0-fjqA7klG6TVp9W8RNo/s320/01-project.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5686119191542579090" /></a><br />On the next screen, select your target api.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdEWtG5n9e2Th_rydcMiCmzZjVdmteRH6TrfB7wm8tCblCPhlUVoKEFPXKOMf_fwX2RSZYyaviqFuI5neGoSOVIYMmbjTCQ1_QwaI_SiGpEbHj8WakVCFrpRf7lTguN7uJ6JTb/s1600/02-platform.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 25px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdEWtG5n9e2Th_rydcMiCmzZjVdmteRH6TrfB7wm8tCblCPhlUVoKEFPXKOMf_fwX2RSZYyaviqFuI5neGoSOVIYMmbjTCQ1_QwaI_SiGpEbHj8WakVCFrpRf7lTguN7uJ6JTb/s320/02-platform.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5686120675890915138" /></a><br /><br />Finally, enter your java package name.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiz3jJnjfNqDT7h7FLWq3NvZyPey1JheQAeF5N3imLhLi56nT1zOdN_h64kUSMfrXXTRnD17dqAXm-I1ecYDiCukH4yvoscm3Jpf2SNQZem81Noj8h1albp2hPWMbIOb4hpH1Nn/s1600/03-package.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 138px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiz3jJnjfNqDT7h7FLWq3NvZyPey1JheQAeF5N3imLhLi56nT1zOdN_h64kUSMfrXXTRnD17dqAXm-I1ecYDiCukH4yvoscm3Jpf2SNQZem81Noj8h1albp2hPWMbIOb4hpH1Nn/s320/03-package.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5686120755293617218" /></a><br /><br />You project should appear in your workspace.<br /><br />Navigate to jibxapp -> res -> layout and double-click main.xml to bring up the form editor.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqFge8M7Oq4uXRyQaM-1SPR-IaWkoKfJS5AWSsuI2VpOiQohRF6OVV0PWsW0MuuFsG3u_N7TVspe2OtsW03aKLjzlMwn7TA2mYySiLZqELcvRgROotrKjskyMp5GaHtTaxpFcN/s1600/04-layout.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 181px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqFge8M7Oq4uXRyQaM-1SPR-IaWkoKfJS5AWSsuI2VpOiQohRF6OVV0PWsW0MuuFsG3u_N7TVspe2OtsW03aKLjzlMwn7TA2mYySiLZqELcvRgROotrKjskyMp5GaHtTaxpFcN/s320/04-layout.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5686120817431105554" /></a><br /><br />Add a button, two medium static text fields, two data text boxes, and a multi-line text box so your screen looks something like this:<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitDgy-n1Au3RV_HCQqip0JmkC7qLRN5rZX3pbvLeUdxAkcdFVo5K_sXm4fU-cgG7_4i3tIymKuGYg8a5Jb0pwLJBNU1vtqbss7PY01aqBrQa_ZfiibWCLlXZ6RQ9YUx869K2d1/s1600/05-screen.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 276px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitDgy-n1Au3RV_HCQqip0JmkC7qLRN5rZX3pbvLeUdxAkcdFVo5K_sXm4fU-cgG7_4i3tIymKuGYg8a5Jb0pwLJBNU1vtqbss7PY01aqBrQa_ZfiibWCLlXZ6RQ9YUx869K2d1/s320/05-screen.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5686120876305509154" /></a><br /><br />You may want to test your Android emulator here by right clicking the project name and selecting 'Debug as' -> 'Android Application'.<br /><br />To add your java binding and the JiBX runtime, right-click your project name and select properties. Click 'java build path' -> Libraries -> 'Add external jars' and add the two jars that we downloaded earlier.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAT8PY33Ywi-2s_ZxiAEwrK1R9KUVVleihDVvo4C-L1U8XD_pEixAriMH77OiliyWCPBIymxiv2W9w6DnX810i6IHXLH3E6FaBTZcxzPt3evSIs7pvFGqSyLDKGgcY4zosEc6O/s1600/07-lib.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 65px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAT8PY33Ywi-2s_ZxiAEwrK1R9KUVVleihDVvo4C-L1U8XD_pEixAriMH77OiliyWCPBIymxiv2W9w6DnX810i6IHXLH3E6FaBTZcxzPt3evSIs7pvFGqSyLDKGgcY4zosEc6O/s320/07-lib.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5686121037448328306" /></a><br /><br />Navigate and open your Android source code file.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYJSXF0vPf8Fc0Ry5FwF1n1hwLHaoWyJk-O2oRzTDzUPOGu2q4QXGK7ANsh9TGOhw_qT9U5C4IoBvdYcA1rNeYrZKxK9-fNZobl2tGNS_i7IQtoVA0Waq5Vza52sin7Xj7vokh/s1600/06-source.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 103px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYJSXF0vPf8Fc0Ry5FwF1n1hwLHaoWyJk-O2oRzTDzUPOGu2q4QXGK7ANsh9TGOhw_qT9U5C4IoBvdYcA1rNeYrZKxK9-fNZobl2tGNS_i7IQtoVA0Waq5Vza52sin7Xj7vokh/s320/06-source.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5686120943045981650" /></a><br /><br />Add this test code to your java source file:<br /><code><br />package org.jibx.android.test;<br /><br />import java.io.ByteArrayOutputStream;<br />import java.io.StringReader;<br />import java.io.UnsupportedEncodingException;<br /><br />import org.jibx.runtime.BindingDirectory;<br />import org.jibx.runtime.IBindingFactory;<br />import org.jibx.runtime.IMarshallingContext;<br />import org.jibx.runtime.IUnmarshallingContext;<br />import org.jibx.runtime.JiBXException;<br />import org.jibx.schema.org.jibx.sampleschema.person.Person;<br /><br />import android.app.Activity;<br />import android.os.Bundle;<br />import android.view.View;<br />import android.widget.Button;<br />import android.widget.EditText;<br /><br />public class JibxappActivity extends Activity {<br />/** Called when the activity is first created. */<br />@Override<br />public void onCreate(Bundle savedInstanceState) {<br /> super.onCreate(savedInstanceState);<br /> setContentView(R.layout.main);<br /><br /> mPickDate = (Button) findViewById(R.id.button1);<br /> mFirstName = (EditText) findViewById(R.id.editText1);<br /> mLastName = (EditText) findViewById(R.id.editText2);<br /> mTextBox = (EditText) findViewById(R.id.editText3);<br /> // add a click listener to the button<br /> mPickDate.setOnClickListener(new View.OnClickListener() {<br /> @Override<br /> public void onClick(android.view.View v) {<br /> doJibxTest();<br /> }<br /> });<br />}<br /><br />Button mPickDate = null;<br />EditText mFirstName = null;<br />EditText mLastName = null;<br />EditText mTextBox = null;<br /><br />/**<br /> * Add the test table records.<br /> */<br />public void doJibxTest() {<br /><b> Person person = new Person();<br /> person.setFirstName(mFirstName.getText().toString());<br /> person.setLastName(mLastName.getText().toString());</b><br /><br /> String xml = marshalMessage(person);<br /> mTextBox.setText(xml);<br /><br /> Person personOut = (Person) unmarshalMessage(xml);<br /><br /> mPickDate.setText(<b>personOut.getFirstName() + ' ' + personOut.getLastName()</b>);<br />}<br /><br />/**<br /> * Marshal this message to xml .<br /> *<br /> * @param message<br /> * @param system<br /> * @return<br /> */<br />public final static String STRING_ENCODING = "UTF8";<br />public final static String URL_ENCODING = "UTF-8";<br />String bindingName = "binding";<br /><br />public String marshalMessage(Object message) {<br /> try {<br /> IBindingFactory jc = BindingDirectory.getFactory(bindingName, Person.class);<br /> IMarshallingContext marshaller = jc.createMarshallingContext();<br /> ByteArrayOutputStream out = new ByteArrayOutputStream();<br /> marshaller.marshalDocument(message, URL_ENCODING, null, out);<br /> return out.toString(STRING_ENCODING);<br /> } catch (UnsupportedEncodingException e) {<br /> e.printStackTrace();<br /> } catch (JiBXException e) {<br /> e.printStackTrace();<br /> }<br /> return null;<br />}<br /><br />/**<br /> * Unmarshal this xml Message to an object.<br /> * @param xml<br /> * @param system<br /> * @return<br /> */<br />public Object unmarshalMessage(String xml) {<br /> try {<br /> IBindingFactory jc = BindingDirectory.getFactory(bindingName, Person.class);<br /> IUnmarshallingContext unmarshaller = jc.createUnmarshallingContext();<br /> return unmarshaller.unmarshalDocument(new StringReader(xml), bindingName);<br /> } catch (JiBXException e) {<br /> e.printStackTrace();<br /> }<br /> return null;<br />}<br />}<br /></code><br /><br />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.<br /><br />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.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl16h1FSZ1qr4gm0LzO-C52qI_gvQYxh1TpGacc5xieQ5XrNGZJQenQLwW61yHzhaXEiCiOixgLJU5K_l-d5euy9H8THbtSAeFX7ESV0gllhNEGGA_KtezqPKK8s8vcooS2mHq/s1600/08-before.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 270px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl16h1FSZ1qr4gm0LzO-C52qI_gvQYxh1TpGacc5xieQ5XrNGZJQenQLwW61yHzhaXEiCiOixgLJU5K_l-d5euy9H8THbtSAeFX7ESV0gllhNEGGA_KtezqPKK8s8vcooS2mHq/s320/08-before.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5686121137115585106" /></a><br /><br />Voilà!<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwFBO3jKREMNibW8oYPYrFryj32XNkHUE5DSs8dQ25oSIsl1X0PGdlkwXJkvI0ohFauGKucxK7gkjAQaUApfnQrL-QE6_FaSFiTrGQL63Wq2eiv7ayl_8CGZrdEvQuR52bd-3b/s1600/09-after.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 190px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwFBO3jKREMNibW8oYPYrFryj32XNkHUE5DSs8dQ25oSIsl1X0PGdlkwXJkvI0ohFauGKucxK7gkjAQaUApfnQrL-QE6_FaSFiTrGQL63Wq2eiv7ayl_8CGZrdEvQuR52bd-3b/s320/09-after.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5686121206288411218" /></a><br /></div></div>Anonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.com54tag:blogger.com,1999:blog-27458610.post-27700966398902585712011-01-31T03:19:00.000-08:002011-01-31T04:18:02.700-08:00Installing git-web on a java web server<div>Installing git-web on a java web server such as tomcat or jetty is pretty simple. All java web-servers have the capability to run cgi scripts such as git-web.<br /><br />The difficult part of installing git-web is setting up all the configuration.<br /><br />First, install git-web using your linux installation tool such as yast, yum, rpm, etc. Your install will assume you will use the apache web server.</div><div><br /></div><div>Now for the hard part. Every linux distro installs the files in different locations. Here is where my files are installed:</div><div>The git-web config file:<br /><span style="font-weight: bold; ">/etc/apache2/conf.d/gitweb.conf</span> (This tells git-web where your repositories are)<br />The git-web install directory:<br /><span style="font-weight: bold; ">/usr/share/git-web</span> (The git-web cgi script and web files)<br /><br />The next step is to get git-web working. There are a ton of tutorials out there. Most of them are pretty bad. I would just open up the gitweb.cgi file in a text editor and edit the parameters.<br /><br />You will probably want to change the $projectroot variable to point to your git repository location.<br /><br />Once you get git-web working, you are ready to install it in your java web server.<br /><br />First, create a war directory (mine is called git-web) and move the git-web files to these locations:</div><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-qr-Doi4rCjFY2HIccMa9k90KjZpZ5QStYyyeRHwwC6-7UXkebJ50lIpRzvM9BAiFBSsMReTxqanRGOJmnSq6MdExqo8WfjH-ykjQn-6JJXGHfB5fzlZnVPWz5J5ZY8m-RC4W/s1600/screen.png"><img style="cursor:pointer; cursor:hand;width: 194px; height: 200px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-qr-Doi4rCjFY2HIccMa9k90KjZpZ5QStYyyeRHwwC6-7UXkebJ50lIpRzvM9BAiFBSsMReTxqanRGOJmnSq6MdExqo8WfjH-ykjQn-6JJXGHfB5fzlZnVPWz5J5ZY8m-RC4W/s200/screen.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5568319120418363394" /></a><br /><br /><div>Next, create the web.xml file in the WEB-INF directory. It should look like this:<br /><code><br /><?xml version="1.0" encoding="UTF-8"?><br /><web-app id="WebApp_ID" version="2.4"<br /> xmlns="http://java.sun.com/xml/ns/j2ee"<br /> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br /> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"><br /> <servlet><br /> <servlet-name>cgi</servlet-name><br /> <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class><br /> <init-param><br /> <param-name>debug</param-name><br /> <param-value>0</param-value><br /> </init-param><br /> <init-param><br /> <param-name>cgiPathPrefix</param-name><br /> <param-value>WEB-INF/cgi-bin</param-value><br /> </init-param><br /> <load-on-startup>5</load-on-startup><br /> </servlet><br /> <servlet-mapping><br /> <servlet-name>cgi</servlet-name><br /> <url-pattern>/gitweb.cgi</url-pattern><br /> </servlet-mapping><br /></web-app><br /></code><br />Voila! Install this war location on your java web server and git-web is ready to go:</div><div><br /></div><div><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitS3kG2aPE2bCApECfEWGEz3Rk2PN0-XKN_a_RVEbd_AJniGxAMFjema1hKPx7Z90I3QN9SMPhz712bJJjpi7H7IvSZVTj1TmYJTl-D8S_voh-kfcUpX4duL-7sqzczhaLe0Jx/s1600/git.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitS3kG2aPE2bCApECfEWGEz3Rk2PN0-XKN_a_RVEbd_AJniGxAMFjema1hKPx7Z90I3QN9SMPhz712bJJjpi7H7IvSZVTj1TmYJTl-D8S_voh-kfcUpX4duL-7sqzczhaLe0Jx/s320/git.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5568320662373998274" style="cursor: pointer; width: 320px; height: 109px; " /></a></div>Anonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.com42tag:blogger.com,1999:blog-27458610.post-42124971492540630792010-01-07T03:37:00.000-08:002010-01-15T12:02:45.268-08:00Creating an OpenTravel Server<div style="text-align: left;"><span class="Apple-style-span" style="font-family:arial;">Here are step-by-step instructions for setting up a server to process messages from the </span><a href="http://www.opentravel.org/"><span class="Apple-style-span" style="font-family:arial;">OpenTravel</span></a><span class="Apple-style-span" style="font-family:arial;"> project.</span></div><div><div><div><span class="Apple-style-span" style="font-family:arial;"><br /></span></div><div><span class="Apple-style-span" style="font-family:arial;">In this tutorial you will create a module to service the OpenTravel "Ping Request".<br /><br /></span><div><b><span class="Apple-style-span" style="font-family:arial;">Prerequisites:</span></b><span class="Apple-style-span" style="font-family:arial;"><br /></span><ol><li><span class="Apple-style-span" style="font-family:arial;">Download my (tiny) </span><a href="http://sourceforge.net/projects/ota-tools/"><span class="Apple-style-span" style="font-family:arial;">opentravel-webservice</span></a><span class="Apple-style-span" style="font-family:arial;"> 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!</span></li><li><span class="Apple-style-span" style="font-family:arial;">Make sure the </span><span class="Apple-style-span" style="font-family:arial;"><a href="http://java.sun.com/">Java</a></span><span class="Apple-style-span" style="font-family:arial;"> sdk is installed.</span></li><li><span class="Apple-style-span" style="font-family:arial;">Install </span><a href="http://maven.apache.org/"><span class="Apple-style-span" style="font-family:arial;">Apache Maven</span></a><span class="Apple-style-span" style="font-family:arial;">. This program auto-installs all the build tools and libraries that you will need. Make sure </span><span class="Apple-style-span" style="font-family:'courier new';">mvn</span><span class="Apple-style-span" style="font-family:arial;"> is in your path.</span></li><li><span class="Apple-style-span" style="font-family:arial;">Install a osgi server. I prefer the fuse distribution of </span><a href="http://fusesource.com/products/enterprise-servicemix4/#download"><span class="Apple-style-span" style="font-family:arial;">Apache Servicemix</span></a><span class="Apple-style-span" style="font-family:arial;">. Almost all web servers can handle osgi modules, but servicemix has some cool capabilities and tutorials (I based this tutorial on their </span><a href="http://fusesource.com/enterprise-support/getting-started/"><span class="Apple-style-span" style="font-family:arial;">getting started tutorial</span></a><span class="Apple-style-span" style="font-family:arial;">).</span></li><li><span class="Apple-style-span" style="font-family:arial;">Install </span><a href="http://www.soapui.org/"><span class="Apple-style-span" style="font-family:arial;">soapui</span></a><span class="Apple-style-span" style="font-family:arial;"> (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.</span></li></ol><div><span class="Apple-style-span" style="font-family:arial;">Now you're ready to get started!</span></div><div><ol><li><span class="Apple-style-span" style="font-family:arial;">Build and Package the webservices modules:<br /><span class="Apple-style-span" style="font-family:'courier new';">> <b>cd {your path}/opentravel-webservice</b><br />> <b>mvn install</b><br />(<span class="Apple-style-span" style="font-family:Verdana, arial, sans-serif;"><span class="Apple-style-span" style="line-height: 16px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><span class="Apple-style-span" style="font-size:x-small;">This may take a while the first time you run it. Ignore the warnings</span></span></span><span class="Apple-style-span" style="font-size:x-small;">)</span></span></span></li><li><span class="Apple-style-span" style="font-family:arial;">Install the web service module and the soap interface to your web server:<br /><span class="Apple-style-span" style="font-family:'courier new';">> <b>cd {your path}/apache-servicemix-{4.1+ version}</b><br />> <b>bin/servicemix</b><br />karaf@root> <b>features:install cxf-osgi</b><br /><span class="Apple-style-span" style="font-size:x-small;">(</span><span class="Apple-style-span" style="line-height: 16px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family:Verdana, arial, sans-serif;"><span class="Apple-style-span" style="font-size:x-small;">Make sure the apache open source services framework is installed</span></span><span class="Apple-style-span" style="font-size:x-small;">)<br /><span class="Apple-style-span" style=" ;font-size:20px;"><span class="Apple-style-span" style="font-size: medium;">karaf@root> </span><b><span class="Apple-style-span" style="font-size: medium;">osgi:install -s mvn:org.apache.servicemix.cxf/org.apache.servicemix.cxf.transport.osgi/4.2.0-fuse-SNAPSHOT</span></b><span class="Apple-style-span" style="font-size: medium;"><br /></span><span class="Apple-style-span" style="font-family:arial;"><span class="Apple-style-span" style="font-size: medium;">(Install the apache http osgi transport)</span></span><br /></span></span>karaf@root> <b>osgi:install -s mvn:org.opentravel/opentravel-webservice-se</b><br /><span class="Apple-style-span" style=" ;font-size:x-small;">(</span><span class="Apple-style-span" style="font-family:Verdana, arial, sans-serif;"><span class="Apple-style-span" style="line-height: 16px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><span class="Apple-style-span" style="font-size:x-small;">Install the opentravel web service module that you just built</span></span></span><span class="Apple-style-span" style="font-size:x-small;">)</span><br />karaf@root> <b>osgi:install -s mvn:org.opentravel/opentravel-webservice-bc</b><br /><span class="Apple-style-span" style="font-size:x-small;">(</span><span class="Apple-style-span" style="font-family:Verdana, arial, sans-serif;"><span class="Apple-style-span" style="line-height: 16px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><span class="Apple-style-span" style="font-size:x-small;">Install the opentravel web service soap binding module that you just built</span></span></span><span class="Apple-style-span" style="font-size:x-small;">)</span><br /></span></span></li><li><span class="Apple-style-span" style="font-family:arial;">Test it! Check out the response when I sent this Ping Message using soapui (in a new shell):<br /><span class="Apple-style-span" style="font-family:'courier new';">> <b>cd {your path}/soapui<br /><span class="Apple-style-span" style="font-weight: normal; "><b><span class="Apple-style-span" style=" font-weight: normal; font-family:arial;"><b><span class="Apple-style-span" style="font-weight: normal; "><span class="Apple-style-span" style="font-family:'courier new';"><b><span class="Apple-style-span" style="font-weight: normal; "></span></b></span></span></b></span></b></span></b></span></span></li><span class="Apple-style-span" style="font-family:arial;"><span class="Apple-style-span" style="font-family:'courier new';"><b><b><b><span class="Apple-style-span" style="font-weight: normal; "><span class="Apple-style-span" style="font-family:'courier new';"><b><span class="Apple-style-span" style="font-weight: normal; "><li style="display: inline !important; "></li><li style="display: inline !important; ">> <b>chmod a+x bin/soapui.sh</b><br /></li></span></b></span></span></b></b><span class="Apple-style-span" style="font-size:x-small;"><span class="Apple-style-span" style="font-weight: normal;"><span class="Apple-style-span" style="font-family:arial;">(Only do this the first time)</span></span></span><br /><span class="Apple-style-span" style=" font-weight: normal; font-family:arial;"><b><span class="Apple-style-span" style="font-weight: normal; "><span class="Apple-style-span" style="font-family:'courier new';"><b><span class="Apple-style-span" style="font-weight: normal; "><li style="display: inline !important; ">> <b>bin/soapui</b></li></span></b></span></span></b></span><br /></b></span><b><span class="Apple-style-span" style="font-weight: normal; "><span class="Apple-style-span" style="font-family:'courier new';"><b><span class="Apple-style-span" style="font-weight: normal; ">File -> New WSDL Project<br /><span class="Apple-style-span" style="font-family:arial;">The url for your WSDL file is: <a href="http://localhost:9090/cxf/openTravelService?WSDL">http://localhost:9090/cxf/openTravelService?WSDL</a></span></span></b></span></span></b></span></ol></div></div></div></div><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqgYlo8NSK9lY2uk61pSl2xipBW76BROO6SgXquW6fcz4Uj1DfzRx8C8pIbqJbF6qLvHXGg_-TDkIubXwnTpiXIIJrxNFlwGto8-vXU39fSenpNdYQ77X-kBiuYOB3ooCSOcN4/s1600-h/soapui1.png"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqgYlo8NSK9lY2uk61pSl2xipBW76BROO6SgXquW6fcz4Uj1DfzRx8C8pIbqJbF6qLvHXGg_-TDkIubXwnTpiXIIJrxNFlwGto8-vXU39fSenpNdYQ77X-kBiuYOB3ooCSOcN4/s400/soapui1.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5426005665369458050" style="cursor: pointer; width: 400px; height: 182px; " /></a><br /><br /><span class="Apple-style-span" style="font-family:arial;">Now try sending a message. Open the tree openTravelBinding -> PingIncommingRequest -> Request and Paste in this simple ping message:</span></div><div><span class="Apple-style-span" style="font-family:arial;"><div><span class="Apple-style-span" style="font-family:'courier new';"><soapenv:envelope soapenv="http://schemas.xmlsoap.org/soap/envelope/" ns="http://www.opentravel.org/OTA/2003/05"></soapenv:envelope></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> <soapenv:header></soapenv:header></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> <soapenv:body></soapenv:body></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> <ns:ota_pingrq target="Production" version="1.005"></ns:ota_pingrq></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><br /></span></div></span></div><div><span class="Apple-style-span" style="font-family:arial;"><div><span class="Apple-style-span" style="font-family:'courier new';"><soapenv:Envelope</span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<soapenv:envelope soapenv="http://schemas.xmlsoap.org/soap/envelope/" ns="http://www.opentravel.org/OTA/2003/05"></soapenv:envelope></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> xmlns:ns="http://www.opentravel.org/OTA/2003/05"></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"><soapenv:Header/></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> <soapenv:Body></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> <ns:OTA_PingRQ Target="Production" Version="1.005"></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> <ns:EchoData>Hello</ns:EchoData></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> </ns:OTA_PingRQ></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"> </soapenv:Body></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"></soapenv:Envelope></span></div></span></div><div><span class="Apple-style-span" style="font-family:'courier new';"></span></div><div style="text-align: left;"><span class="Apple-style-span" style="font-family:arial;"><i><span class="Apple-style-span"><i><span class="Apple-style-span" style="font-family:arial, sans-serif;"><em style="font-weight: bold; "><span class="Apple-style-span" style=" font-weight: normal; font-family:arial;"><i><span class="Apple-style-span" style="line-height: 29px; font-family:'Times New Roman', 'Times Serif', serif;"><strong style=" margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family:arial, verdana, sans-serif;font-size:inherit;"><span class="Apple-style-span" style="font-size:medium;"><br /></span></strong></span></i></span></em></span></i></span></i></span></div><div style="text-align: left;"><span class="Apple-style-span" style="font-family:arial;"><i><span class="Apple-style-span"><i><span class="Apple-style-span" style="font-family:arial, sans-serif;"><em style="font-weight: bold; "><span class="Apple-style-span" style=" font-weight: normal; font-family:arial;"><i><span class="Apple-style-span" style="line-height: 29px; font-family:'Times New Roman', 'Times Serif', serif;"><strong style=" margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family:arial, verdana, sans-serif;font-size:inherit;"><span class="Apple-style-span" style="font-size:medium;">Voilà,</span><span class="Apple-style-span" style=" font-weight: normal; line-height: normal; font-family:arial;"><i><span class="Apple-style-span"><i><span class="Apple-style-span" style="font-family:arial, sans-serif;"><em style="font-weight: bold; "><span class="Apple-style-span" style=" font-weight: normal; font-family:arial;"><i><span class="Apple-style-span" style="font-family:arial, sans-serif;"><em style="font-weight: bold; "><span class="Apple-style-span" style=" font-weight: normal; font-family:arial;"><i><span class="Apple-style-span" style="font-size:medium;"> You've been pinged!</span></i></span></em></span></i></span></em></span></i></span></i></span></strong></span></i></span></em></span></i></span></i></span></div><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBhGFHgAjtk0eTCAYZ523qmFq40DFkbPpxnU2t8FM9GWCEXx_-5aiJcTmCY4iwAwAPZIZIlm27amFT19d2CIZK8eZU0Uw_QJoVj31qenmXvdabPXvqLMMmwyrJoVbqgcOD1wgT/s1600-h/soapui2.png"><img style="text-align: center;float: left; margin-top: 0px; margin-right: 10px; margin-bottom: 10px; margin-left: 0px; cursor: pointer; width: 400px; height: 77px; " src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBhGFHgAjtk0eTCAYZ523qmFq40DFkbPpxnU2t8FM9GWCEXx_-5aiJcTmCY4iwAwAPZIZIlm27amFT19d2CIZK8eZU0Uw_QJoVj31qenmXvdabPXvqLMMmwyrJoVbqgcOD1wgT/s400/soapui2.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5426006639724748466" /></a><div style="text-align: center;"><span class="Apple-style-span" style="color:#0000EE;"><u><br /></u></span></div><div><div style="text-align: center;"><span class="Apple-style-span" style="font-family: arial; "><br /></span></div><div style="text-align: center;"><span class="Apple-style-span" style="font-family: arial; "><br /></span></div><div style="text-align: center;"><span class="Apple-style-span" style="font-family: arial; "><br /></span></div><div style="text-align: center;"><span class="Apple-style-span" style="font-family: arial; "><br /></span></div><div style="text-align: center;"><span class="Apple-style-span" style="font-family: arial; ">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</span></div><div><span class="Apple-style-span" style="font-family:arial;"><br /></span></div><div><span class="Apple-style-span" style="font-family:arial;"><span class="Apple-style-span" style=" color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; font-family:Georgia, serif;"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEMLtOsG3PKJEgJl3GapkN_z8Gm0bPmk6rgX3ScpXvzmNv16aBmrx9yCRRiJs23IcMWG6Az7xTFOMi0W-R95ZEt07SbMpRZQaRyetUdg0-JIjGzXP_I50K3khoiPXhBOugc4Mt/s400/soapui3.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5427058776712448146" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 77px; " /></span></span></div><div><span class="Apple-style-span" style="font-family:arial;"><br /></span></div><div><span class="Apple-style-span" style="font-family:arial;">Now open the test suite and hit the run button. Cool, all the tests are successful!</span></div><div><span class="Apple-style-span" style="font-family:arial;"><br /></span></div><div><span class="Apple-style-span" style="font-family:arial;"><span class="Apple-style-span" style="font-family: Georgia, serif; color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmzqKkriu6QdWHuUhmghT416YjHzwi6PuN08XABx4OdjagpIEGYBDjkDTN-QTcfjKA0NU6do_jmrL7jadHkYBsX5On6A53f0nP2EhrN7Qyli7CWAHGqBaaLDbxfMvx0z5D2fBE/s400/soapui4.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5427059060315455714" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 318px; " /></span></span></div><div><span class="Apple-style-span" style="font-family:arial;"><span class="Apple-style-span" style="font-family: Georgia, serif; color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "><br /></span></span></div><div><span class="Apple-style-span" style="font-family:arial;">This project is a great starting point for your OpenTravel implementation or test project.</span></div><div><span class="Apple-style-span" style="font-family:arial;"><br /></span></div><div><span class="Apple-style-span" style="font-family:arial;">Please leave a comment if would like more blogs on this subject... or if you have any questions or recommendations!</span></div></div>Anonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.com14tag:blogger.com,1999:blog-27458610.post-17667322324987489902009-02-27T09:53:00.000-08:002009-03-24T12:21:45.310-07:00Enabling Java Web Start on Linux FirefoxTo Enable Java Web Start on Linux Firefox:<br />1. Remove the IcedTea java plugin (libjavaplugin.so or javaplugin.so) link in /usr/lib64/browser-plugins. (or lib for 32 bit systems)<br />2. Create a link to the sun java plugin in the /usr/lib64/browser-plugins directory:<br /><blockquote>ln -s /usr/local/java/jdk/jre/lib/amd64/libnpjp2.so libnpjp2.so</blockquote><br />(Use your java path)<br />That's it!<br />To make sure your plugin in installed type:<br /><blockquote>about:plugins</blockquote><br />in the firefox address window.<br />To test the plug-in using a jnlp webstart applet, Click the '<span style=""><a href="http://www.donandann.com/bio">Biorhythm applet</a>' icon on this page:<br /><a href="http://www.donandann.com/bio/">http://www.donandann.com/bio/</a><br />Voila!<br />If webstart stops working, it is probably due to an update adding back the icedtea link. Just delete the link and webstart will work again.<br /></span>Anonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.com28tag:blogger.com,1999:blog-27458610.post-5439573494515451372008-09-14T23:33:00.000-07:002008-09-15T00:57:57.908-07:00Creating jaxb files from the opentravel schema<span style="font-family:arial;">Probably the easiest way to deal with complicated xml documents is to use the jaxb tool from java.</span> <span style="font-family:arial;">jaxb converts a schema definition from .xsd format to java classes.</span> <span style="font-family:arial;">If you are trying to use jaxb on the </span><a style="font-family: arial;" href="http://www.opentravel.org/">opentravel.org</a><span style="font-family:arial;"> schema there are a few gotchas:</span> <ul style="font-family: arial;"><li>First, since the schema is so large, there are a few places where there are duplicate element names.</li><li>Second, since the schema was not developed with jaxb in mind, there are a few element names (such as 'class') that are not legal in java.</li></ul><span style="font-family:arial;">Luckily, I wrote a utili</span><span style="font-family:arial;">ty that m</span><span style="font-family:arial;">akes it a lot ea</span><span style="font-family:arial;">sier to use jaxb, called ota-schema-tools. This is part of the open source </span><a style="font-family: arial;" href="http://ota-tools.sourceforge.net/">ota-tools project</a><span style="font-family:arial;">. You can download these tools at the </span><a style="font-family: arial;" href="http://sourceforge.net/projects/ota-tools">sourceforge project page</a><span style="font-family:arial;">.</span> <span style="font-family:arial;">After you have downloaded the tools, unzip them into a directory.<br /><br />After a few quick steps, the schema tool is ready to go:<br />1. Download the sch</span><span style="font-family:arial;">ema(s) that </span><span style="font-family:arial;">you want to</span><span style="font-family:arial;"> use from </span><a style="font-family: arial;" href="http://www.opentravel.org/">opentravel.org</a><span style="font-family:arial;"> and drop it in the <span style="font-family:courier new;">ota-schema-zip-files</span> directory:<br /></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK8FLazbaFawHC9LpbM0a6Ko29BznpWnDjDCsEFVirejrTru1Uhy4KlfuqFNQGE_apHN2YXWVJu_rr8T20b4RJm5BEMVq2A1fJApO2xB3zYrQLVEIgXrp0gq6Ec4SjZMDA1LQS/s1600-h/folder.jpg"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK8FLazbaFawHC9LpbM0a6Ko29BznpWnDjDCsEFVirejrTru1Uhy4KlfuqFNQGE_apHN2YXWVJu_rr8T20b4RJm5BEMVq2A1fJApO2xB3zYrQLVEIgXrp0gq6Ec4SjZMDA1LQS/s320/folder.jpg" alt="" id="BLOGGER_PHOTO_ID_5246139962430420162" border="0" /></a><br /><span style="font-family:arial;">2. Edit the ota.xsd file in the ota-schema-tools/config/2008A directory to include only the schema you will need (or leave it alone to compile al</span><span style="font-family:arial;">l the schema). For example, here I only want to use the OTA_Ping messages:</span><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkY3lsboieu47-xLrFee3SjKdqdIB_N1gA1qSPKhKL8EnYrKcjwtmhEGt9XEb3k0tcfCxaEe9z8EFFGf8FKB2xvCWmEmpVJgM8muac7R0fpyt4P04fvLk4ylc5BzCaFPiIjjLg/s1600-h/ota.jpg"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkY3lsboieu47-xLrFee3SjKdqdIB_N1gA1qSPKhKL8EnYrKcjwtmhEGt9XEb3k0tcfCxaEe9z8EFFGf8FKB2xvCWmEmpVJgM8muac7R0fpyt4P04fvLk4ylc5BzCaFPiIjjLg/s400/ota.jpg" alt="" id="BLOGGER_PHOTO_ID_5246141494972609746" border="0" /></a><br /><span style="font-family:arial;">3. Run the schema tool:<br />If jaxb is not in your classpath, you will need to tell ant where it is wi</span><span style="font-family:arial;">th the<span style="font-family:courier new;"> -Djaxb.home=<span style="font-style: italic;">/location-of-jaxb-home</span> flag</span>. Also, if you are compiling a lot of schemas, you will have to set the <span style="font-family:courier new;">ANT_OPTS=<span style="font-style: italic;">javac-options</span></span> property. Here is what I type:<br /></span><blockquote><span style="font-family:arial;"><span style="font-family:courier new;">ota-schema-tools> export ANT_OPTS=-Xmx512m</span> </span><span style="font-family:courier new;">ota-schema-tools> ant -Djaxb.home=/usr/local/java/web/glassfish/ dist</span></blockquote><br /><span style="font-family:arial;">When I run this command I get the error: </span><span style="font-family:arial;"><span style="font-family:courier new;">OTA_TourInformation.xsd</span> and <span style="font-family:courier new;">OTA_RailAvailRS.xsd</span> is not a part of this compilation</span>.<br /><span style="font-family:arial;">No problem. The jaxb configuration file is set up to fix problems in the entire schema. Just remove these lines from the <span style="font-family:courier new;">ota-schema-tools/config/2008A/jaxb/binding.xj</span></span><span style="font-family:arial;"><span style="font-family:courier new;">b</span> file:<br /></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBi95U5nmYUExpSlwkEnNJVA5kkkH-16x_-dQFbtpm1tHlDcdew4vc-BNz0kzpeoc7GK1HHaPJ0pOtRulSy5KyrvDybfA4xpPqO93mO7xG13QYPu8s1h_XCpSf9cTofCBVJMVR/s1600-h/jaxb.jpg"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBi95U5nmYUExpSlwkEnNJVA5kkkH-16x_-dQFbtpm1tHlDcdew4vc-BNz0kzpeoc7GK1HHaPJ0pOtRulSy5KyrvDybfA4xpPqO93mO7xG13QYPu8s1h_XCpSf9cTofCBVJMVR/s400/jaxb.jpg" alt="" id="BLOGGER_PHOTO_ID_5246147438085640194" border="0" /></a><br /><span style="font-family:arial;">I deleted these highlighted lines. Now run this line again from your command prompt:<br /></span><span style="font-family:courier new;">ant -Djaxb.home=/usr/local/java/web/glassfish/ dist<br /><span style="font-family:arial;"></span></span><em style="font-family: arial; font-style: italic;">Voila</em><span style="font-style: italic;font-family:arial;" >!</span><span style="font-family:courier new;"> <span style="font-family:arial;">Your schema are compiled and neatly packaged in a opentravel2008a.jar file.<br /><br />Now that wasn't that hard, was it!<br /></span></span><br /><img src="file:///tmp/moz-screenshot.jpg" alt="" />Anonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.com25tag:blogger.com,1999:blog-27458610.post-59420505364554305292008-09-12T14:37:00.000-07:002008-09-12T22:10:15.255-07:00awstats web site statistics for glassfish<a href="http://awstats.sourceforge.net/">awstats</a> is a open source web server log analyzer. <a href="http://glassfish.dev.java.net/">Glassfish</a> is an open source java-based web-server. Click here to check out the statistics on my two glassfish domain servers: <a href="http://www.donandann.com/awstats/awstats.pl?config=domain1">domain1</a> <a href="http://www.donandann.com/awstats/awstats.pl?config=domain2">domain2</a>. <span style="font-size:85%;">Of course you will restrict access when you deploy this.</span><br /><br />To get the awstats package to work with glassfish:<br /><ol><li>Download and untar <a href="http://awstats.sourceforge.net/">awstats</a> (to /usr/local/awstats)</li><li>Follow the instructions for installing awstats and run the configuration utility.<br />Remember to create the /etc/awstats/ and /var/lib/awstats/ directories and set write permission.<br />Edit the config file (/etc/awstats/<span style="font-style: italic;">yourconfigfilename</span>) and change the LogFile property to:<br /><span style="font-family:courier new;">LogFile="sed -e 's/"\([0-9\.]*\)"/\1 - -/g' -e 's/"\([^"]*-0800\)"/[\1]/g' </span><span style="font-style: italic;font-family:courier new;" >/usr/local/java/web/glassfish</span><span style="font-family:courier new;">/domains/domain1/logs/access/server_access_log.%YYYY-0-%MM-0-%DD-0.txt |"</span><br />where<span style="font-family:courier new;"> "</span><span style="font-style: italic;font-family:courier new;" >/usr/local/java/web/glassfish</span><span style="font-family:courier new;">"</span> is the location of your glassfish server. Also remember to change the time zone offset (mine is -0800) to your timezome offset.<br />Change the DirIcons property to:<br /><span style="font-family:courier new;">DirIcons="icon"<br /></span>You will probably want to change your SiteDomain and HostAliases properties to match your domain name.<br />I got this info from <a href="http://blogs.bytecode.com.au/glen/2006/11/14/1163471354835.html">Glen Smith's blog</a>, Thanks!</li><li>Open your glassfish admin page (http://www.yourserver.com:4848), go to configuration -> http service and click the Access Logging <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn73IGmgOQMaiYfTuiuBQo3VsHGtGBfl3CeUj3_F0ItDCmwVf6ffbN7lyj5VUVr8Pk71NQFR7I08ppJ9X4lEIbL9OW-MrGsAF3H_TsdgNBOA8IM7jcxNOd8Hq_2R1aCpF1Ld7f/s1600-h/enabled.jpg"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn73IGmgOQMaiYfTuiuBQo3VsHGtGBfl3CeUj3_F0ItDCmwVf6ffbN7lyj5VUVr8Pk71NQFR7I08ppJ9X4lEIbL9OW-MrGsAF3H_TsdgNBOA8IM7jcxNOd8Hq_2R1aCpF1Ld7f/s200/enabled.jpg" alt="" id="BLOGGER_PHOTO_ID_5245294732444165426" border="0" /></a> enabled box.<br />Click on the Access Log Tab and enter:<br /><span style="font-family:courier new;">%client.name% %datetime% %request% %status% %response.length% %header.referer% %header.user-agent%</span><br />in the Format text box.<br />This makes your log format similar to the apache log format</li><li>Go you your awstats/wwwroot directory and create a sub-directory WEB-INF<br />Create a web.xml file in this directory that contains:<br /><br /><?xml version="1.0" encoding="UTF-8"?><br /><web-app id="WebApp_ID" version="2.4"<br />xmlns="http://java.sun.com/xml/ns/j2ee"<br />xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"><br /><servlet><br /><servlet-name>cgi</servlet-name><br /><servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class><br /><init-param><br /> <param-name>debug</param-name><br /> <param-value>0</param-value><br /></init-param><br /><init-param><br /> <param-name>cgiPathPrefix</param-name><br /> <param-value>cgi-bin</param-value><br /></init-param><br /> <load-on-startup>5</load-on-startup><br /></servlet><br /><servlet-mapping><br /> <servlet-name>cgi</servlet-name><br /><url-pattern>/awstats.pl</url-pattern><br /></servlet-mapping><br /></web-app><br />Afterwards, cd to the wwwroot/cgi-bin directory type chmod a-w *.pl just to be careful.</li><li>Now, install this as a web server in the glassfish admin screen (http://www.yourserver.com:4848)<br />Applications -> Web Applications -> Deploy<br />And deploy the web server directory: <span style="font-family:courier new;">/usr/local/awstats/wwwroot</span>. Make sure your context root is <span style="font-family: courier new;">awstats</span>.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2I3h65wzzGanXDUjUGo5TWunwv401C7vaecb-LNc5QNwLLpKaQLQ3SNyn7dXTEHUpYzhtkL0nz4NWHVDxfettw7IPsdCVOmCxx8-txFbXNIma9ZhXWlIrj1FJsvvIxP9ntaAB/s1600-h/deployscreen.jpg"><img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2I3h65wzzGanXDUjUGo5TWunwv401C7vaecb-LNc5QNwLLpKaQLQ3SNyn7dXTEHUpYzhtkL0nz4NWHVDxfettw7IPsdCVOmCxx8-txFbXNIma9ZhXWlIrj1FJsvvIxP9ntaAB/s320/deployscreen.jpg" alt="" id="BLOGGER_PHOTO_ID_5245344029390027602" border="0" /></a><br /><br /></li><li>Try to invoke the servlet as it's described in the awstats documentation:<br />http://<span style="font-style: italic;">www.yourdomain.com</span>/awstats/awstats.pl?config=<span style="font-style: italic;">yourconfigfilename</span><br />You should see the awstat config data. Cool!<br /></li></ol>Anonymoushttp://www.blogger.com/profile/01447185242361881667noreply@blogger.com103