9 Web services

 9.1 Displaying a time series using web serices
 9.2 Creating a Fourier Transform using web serices

While FROG can be used locally as a normal application, it also exposes functionality via a built in web server as a SOAP web service. The web service is language neutral and can be accessed using a variety of SOAP toolkits in languages that include Perl, Python, PHP, Java, C, C++ and even Fortran.

This means FROG can be used from your own code or scripts for either display, or data processing, without having to learn Java or write alot of code. Client side programs can be as short as a few lines depending on the language and toolkit chosen.

FROG currently provides two web service endpoints.

9.1 Displaying a time series using web serices

The web service interface allows FROG to be used as a display tool. The interfface will allows the user to load and display a time series by passing a SOAP message to the FROG web server.

Below is an example Perl script using the SOAP::Lite toolkit to access the FROG web service to display a time series.

    #!/usr/bin/perl
  
    use SOAP::Lite;
    use Getopt::Long;
  
    unless ( scalar @ARGV >= 1 ) {
       die "USAGE: $0 [-host host] [-port port] -file filename\n";
    }
  
    my $status = GetOptions( "host=s"       => \$host,
                             "port=s"       => \$port,
                             "file=s"       => \$file );
  
    # default hostname
    unless ( defined $host ) {
       # localhost.localdoamin
       $host = "127.0.0.1";
    }
  
    # default port
    unless( defined $port ) {
       # default port for the user agent
       $port = 8084;
    }
  
    my $data;
    if( defined $file ) {
       unless ( open ( FILE, "<$file") ) {
          die "ERROR: Cannot open $file\n";
       }
       undef $/;
       $data = <FILE>;
       close FILE;
    } else {
       die "ERROR: No data file specified.\n";
    }
  
    my $service = SOAP::Lite->service(
        "http://$host:$port/services/FrogSOAPServices?wsdl" );
  
    print $service->displaySeries( $data ) . "\n";

9.2 Creating a Fourier Transform using web serices

The web service interface also allows FROG to be used as an algorithim engine, the example Perl script below dispatches a time series to FROG which then calculates and returns a Fourier Transform for the series between the limits provided.

    #!/usr/bin/perl
  
    use SOAP::Lite;
    use Getopt::Long;
  
    unless ( scalar @ARGV >= 1 ) {
       die "USAGE: $0 [-host host] [-port port] -file filename\n";
    }
  
    my $status = GetOptions( "host=s"       => \$host,
                             "port=s"       => \$port,
                             "file=s"       => \$file,
                             "min=s"        => \$min_freq,
                             "max=s"        => \$max_freq,
                             "interval=s"   => \$interval );
  
    # default hostname
    unless ( defined $host ) {
       # localhost.localdoamin
       $host = "127.0.0.1";
    }
  
    # default port
    unless( defined $port ) {
       # default port for the user agent
       $port = 8084;
    }
  
    my $data;
    if( defined $file ) {
       unless ( open ( FILE, "<$file") ) {
          die "ERROR: Cannot open $file\n";
       }
       undef $/;
       $data = <FILE>;
       close FILE;
    } else {
       die "ERROR: No data file specified.\n";
    }
  
    my $service = SOAP::Lite->service(
        "http://$host:$port/services/FrogSOAPServices?wsdl" );
  
    print $service->getFourierTransform(
                       $data, $min_freq, $max_freq, $interval ) . "\n";