[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Tue Apr 29 19:58:38 UTC 2008


kawas
Tue Apr 29 15:58:37 EDT 2008
Update of /home/repository/moby/moby-live/Perl/MOSES-MOBY/bin/scripts
In directory dev.open-bio.org:/tmp/cvs-serv10354/Perl/MOSES-MOBY/bin/scripts

Modified Files:
	moses-testing-service.pl moses-generate-services.pl 
Log Message:
added support for biomoby services of category cgi 
moby-live/Perl/MOSES-MOBY/bin/scripts moses-testing-service.pl,1.3,1.4 moses-generate-services.pl,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOSES-MOBY/bin/scripts/moses-testing-service.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOSES-MOBY/bin/scripts/moses-testing-service.pl	2008/02/21 00:12:55	1.3
+++ /home/repository/moby/moby-live/Perl/MOSES-MOBY/bin/scripts/moses-testing-service.pl	2008/04/29 19:58:37	1.4
@@ -9,15 +9,17 @@
 BEGIN {
     # some command-line options
     use Getopt::Std;
-    use vars qw/ $opt_h $opt_d $opt_v $opt_l $opt_e /;
-    getopts ('hdvl:e:');
+    use vars qw/ $opt_h $opt_d $opt_v $opt_l $opt_e $opt_c /;
+    getopts ('hdvl:e:c:');
 
     # usage
-    if ($opt_h or @ARGV == 0) {
+    if ($opt_h or (@ARGV == 0 and (not $opt_c))) {
 	print STDOUT <<'END_OF_USAGE';
 Calling a BioMoby services (without using SOAP, just locally).
 Usage: # calling a local module representing a service, without using SOAP
        [-vd] [-l <lib-location>] <package-name> [<input-file>]
+       or
+       [-vd] -c <service-url> [<input-file>]
 
        It also needs a location of a local cache (and potentially a
        BioMoby registry endpoint). It takes it from the
@@ -26,6 +28,9 @@
        # calling a real service, using SOAP
        -e <service-url> <service-name> [<input-file>]
 
+       # calling a real service, using cgi
+       -c <service-url> [<input-file>]
+
     <package-name> is a full name of a called module (service)
         e.g. Service::Mabuhay
 
@@ -37,6 +42,10 @@
         A service endpoint
         (e.g. http://localhost/cgi-bin/MobyServer.cgi)
 
+    -c <cgi-service-url>
+        A cgi biomoby service url
+        (e.g. http://localhost/cgi-bin/HelloBiomobyWorld.cgi)
+
     <input-file>
         A BioMoby XML file with input data.
         Default: an empty BioMoby request
@@ -55,7 +64,13 @@
 	eval "use SOAP::Lite; 1;"
 	    or die "$@\n";
 
-    } else {
+    } elsif ($opt_c) {
+    	# calling a real service, using cgi
+    	eval "use HTTP::Request::Common qw(POST); 1;"
+	    or die "$@\n";
+	    eval "use LWP::UserAgent; 1;"
+	    or die "$@\n";
+    }else {
 	# calling a local service module, without SOAP
 	eval "use MOSES::MOBY::Base; 1;";
 	# take the lib location from the config file
@@ -83,7 +98,7 @@
 # --- what service to call
 my $module = shift;   # eg. Service::Mabuhay, or just Mabuhay
 my $service;
-($service = $module) =~ s/.*:://;
+($service = $module) =~ s/.*::// unless $opt_c;
 
 # --- call the service
 if ($opt_e) {
@@ -115,6 +130,24 @@
 	-> $service (SOAP::Data->type('string' => "$input"))
         -> result;
 
+} elsif ($opt_c) {
+    # calling a real service, using cgi
+    my $ua = LWP::UserAgent->new;
+ 
+    my $input = '';
+    if (@ARGV > 0) {
+	my $data = shift;     # a file name
+	open INPUT, "<$data"
+	    or die "Cannot read '$data': $!\n";
+	while (<INPUT>) { $input .= $_; }
+	close INPUT;
+    } else {
+	$input = _empty_input;
+    }
+
+	my $req = POST $opt_c, [ data => $input];
+	print "\n" . $ua->request($req)->as_string . "\n";
+
 } else {
     # calling a local service module, without SOAP
     my $data;

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOSES-MOBY/bin/scripts/moses-generate-services.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOSES-MOBY/bin/scripts/moses-generate-services.pl	2008/02/21 00:12:55	1.3
+++ /home/repository/moby/moby-live/Perl/MOSES-MOBY/bin/scripts/moses-generate-services.pl	2008/04/29 19:58:37	1.4
@@ -8,7 +8,7 @@
 
 # some command-line options
 use Getopt::Std;
-use vars qw/ $opt_h $opt_d $opt_v $opt_a $opt_s $opt_b $opt_f $opt_u $opt_F $opt_S $opt_t/;
+use vars qw/ $opt_h $opt_d $opt_v $opt_a $opt_s $opt_b $opt_f $opt_u $opt_F $opt_S $opt_t $opt_c /;
 getopt;
 # usage
 if (not($opt_u or $opt_f)) {
@@ -31,11 +31,13 @@
     -S ... generate implementation and the base of service[s], the
            implementation module has enabled option to read the base
            statically (that is why it is also generated here)
+    -i ... generate an implementation of the given service
+    -c ... generate a cgi based implementation of the given service       
     -t ... update dispatch table of services (a table used by the
 	   cgi-bin script and SOAP::Lite to dispatch requests);
            this table is also updated automatically when options
            -i or -S are given
-    If none of -b, -S, -t is given, it generates/show implementation
+    If none of -b, -S, -t, -c is given, it generates/show implementation
     (not a base) of service[s].
 
     -s ... show generated code on STDOUT
@@ -99,6 +101,9 @@
 	$generator->generate_impl (static_impl => 1);
 	$generator->generate_base;
 	$generator->update_table;
+    }  elsif ($opt_c) {
+    $generator->generate_impl;
+	$generator->generate_cgi;
     } elsif ($opt_t) {
 	$generator->update_table;
     } else {
@@ -114,7 +119,14 @@
 	    $generator->generate_base (service_names => [@ARGV],
 				       authority     => $authority,
 				       outcode       => \$code);
-	} else {
+	} elsif ($opt_c) {
+    	$generator->generate_impl(service_names => [@ARGV],
+				       authority     => $authority,
+				       outcode       => \$code);
+		$generator->generate_cgi(service_names => [@ARGV],
+				       authority     => $authority,
+				       outcode       => \$code);
+    } else {
 	    $generator->generate_impl (service_names => [@ARGV],
 				       authority     => $authority,
 				       outcode       => \$code);
@@ -133,7 +145,14 @@
 				       authority     => $authority);
 	    $generator->update_table (service_names => [@ARGV],
 				      authority     => $authority);
-	} elsif ($opt_t) {
+	}  elsif ($opt_c) {
+    	$generator->generate_impl(
+					service_names => [@ARGV],
+					authority     => $authority,
+					force_over    => $opt_F);
+		$generator->generate_cgi(service_names => [@ARGV],
+				      authority     => $authority);
+    } elsif ($opt_t) {
 	    $generator->update_table (service_names => [@ARGV],
 				      authority     => $authority);
 	} else {




More information about the MOBY-guts mailing list