Monday, September 17, 2007

Using CHRONOS Timescale Converter Service Calls

The timescale converter web application accessible through the CHRONOS portal (Ref: http://portal.chronos.org/gridsphere/gridsphere?cid=tools_tsconvert) uses publicly available web service calls to the timescale service described by the WSDL document located at http://services.chronos.org:9090/axis/timescales.jws?wsdl. These services are available for use on any platform.

Simple clients to these end points can be created in any modern programming language. Examples using Python and Groovy, two popular dynamic languages, are given below. Examples using Ruby or C# would be quite similar.

Example using Python

#!/usr/bin/python
#

import re, string
from SOAPpy import SOAPProxy

server = SOAPProxy("http://services.chronos.org:9090/axis/timescales.jws")
time = 20.0

while time < 40.0:

result = server.convertTime("GTS 2004", "Berggren 95",time)

print time , result

time = time + 0.1



Example using Groovy

import groovy.net.soap.SoapClient

def proxy = new SoapClient("http://services.chronos.org:9090/axis/timescales.jws?wsdl")


def serviceClosure = {

time -> return proxy.convertTime("GTS 2004", "Berggren 95", time)
}

for (float f = 20;f< 40.0; f=f+0.1) {
println serviceClosure(f)
}

A slightly more advanced example of a real-world application of these services is the implementation of the service in a Java-based web application server. In this case, a user would use e.g. the Xfire (http://xfire.codehaus.org/Client+and+Server+Stub+Generation+from+WSDL) or Apache Axis (http://ws.apache.org/axis/java/client-side-axis.html) packages to generate a library from the WSDL file. The resulting library could then be easily called from various locations in the application with only a few lines of code.

The first step would involve the creation of the stub classes in a WSDL-to-Java process. We will use the Apache Axis package in this example but the process is similar for Xfire or C# style environments. The initial stub classes are generated through a call like:

java -cp axis.jar:commons-logging-1.0.4.jar:commons-discovery-0.2.jar:axis-ant.jar:log4j-1.2.8.jar:wsdl4j-1.5.1.jar:jaxrpc.jar:saaj.jar org.apache.axis.wsdl.WSDL2Java -o . -d Session -p org.chronos.ws http://services.chronos.org:9090/axis/timescales.jws?wsdl

The result of this call is a set of Java source files that would then be compiled:

javac -classpath axis.jar:commons-logging-1.0.4.jar:commons-discovery-0.2.jar:axis-ant.jar:log4j-1.2.8.jar:wsdl4j-1.5.1.jar:jaxrpc.jar:saaj.jar org/chronos/ws/*.java

and the resulting class files collected into a jar file:

jar -cvf timescale.jar org/chronos/ws/*.class

The resulting jar file can then be used to greatly simplify the creation of clients in Java or any other Java byte code compatible language like Jruby, Jpython or Groovy.

An example of Java client that gets the color scheme for the Geological Time Scale is:

public class wsClient {
public static void main(String [] args) throws Exception {

// Make a service
org.chronos.ws.TimescalesService service = new org.chronos.ws.TimescalesServiceLocator();

// Now use the service to get a stub to the service org.chronos.ws.Timescales_PortType ts = service.gettimescales();

// Make the actual call

System.out.println("call " + ts.getColorScales());

}

}


A Groovy client that uses the jar file (here using the batch convert method for time conversion) is:
import java.text.DecimalFormat

// Make a service

def org.chronos.ws.TimescalesService service = new org.chronos.ws.TimescalesServiceLocator();

// Now use the service to get a stub to the service

def org.chronos.ws.Timescales_PortType ts = service.gettimescales();

// Make the actual call

def batchResults = (ts.convertTimeBatch("GTS 2004", "Berggren 95", 0.toDouble(), 60.toDouble(), 1.toDouble()));


DecimalFormat df2 = new DecimalFormat( "#,###,###,##0.000" );

// Closure for 2 place formating

def decf2 = {

value -> return new Double(df2.format(value)).doubleValue();

}

for (item in batchResults) {
println decf2(item)
}


These examples illustrate the process involved in the creation of clients using only the WSDL URL. Once created, jar libraries like those at the end of the process can be dropped into application server class paths and used in frameworks like Grails (http://www.grails.org), Seam ( http://www.jboss.com/products/seam) or JSR-168 portal environments like Gridsphere (http://www.gridsphere.org). Any application or tool with network access can invoke these services in a similar manner.

All CHRONOS services a similar pattern and can be utilized in web-based or stand-alone clients that have access to the network.

6 comments:

Anonymous said...

Easy Answering

http://www.easyanswering.com

Anonymous said...

http://damncoolpics.blogspot.com/2007/09/meet-littlest-angel-kenadie-jourdin.html

Remon said...

video converter software free download:
http://www.dvd-creators.net/video-converter.html

ASF converter to convert avi to asf, asf to avi, flv to av, etc:
http://www.asf-converter.com/

Satya said...

The place where the fun never ends
http://Gisnap.com

Satya said...

The place where you find news updates instantly.

Unknown said...

Do you know what .MTS is? The .MTS file format is extension of AVCHD video format which is based on the popular MPEG-4 video codec and is a high definition MPEG, AVC, H.264 transport stream video file format. Do you want to own a powerful MTS Converter and then use it to help you to convert mts file to avi,convert mts file to mpg, convert mts file to mp4, convert mts file to 3gp, convert mts to vob, convert mts to mov. To do this conversion, I also can share with you MTS to AVI Converter and MTS to MPG Converter or MTS to MPEG Converter