[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Wed Jun 11 20:36:59 UTC 2003
mwilkinson
Wed Jun 11 16:36:59 EDT 2003
Update of /home/repository/moby/moby-live/Perl/MOBY/Client
In directory pub.open-bio.org:/tmp/cvs-serv6050/MOBY/Client
Modified Files:
Central.html Central.pm Service.html Service.pm
ServiceInstance.html ServiceInstance.pm
Log Message:
last minute commit of all of my changes before I bugger off for the weekend.
moby-live/Perl/MOBY/Client Central.html,1.3,1.4 Central.pm,1.32,1.33 Service.html,1.1,1.2 Service.pm,1.3,1.4 ServiceInstance.html,1.1,1.2 ServiceInstance.pm,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.html 2003/06/10 23:58:26 1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.html 2003/06/11 20:36:59 1.4
@@ -262,43 +262,42 @@
<h2><a name="findservice">findService</a></h2>
<pre>
Title : findService
- Usage : $REG = $MOBY->findService(%args)
+ Usage : $ServiceInstances = $MOBY->findService(%args)
Function : deregister a registered MOBY Service
- Returns : MOBY::Registration object
+ Returns : arrayref of MOBY::Client::ServiceInstance objects
Args :
- serviceName => $serviceName,
- serviceType => $serviceType,
- authURI => $authURI,
- authoritative => 1,
- category => "moby" | "cgi" | "soap" (currently only moby supported)
- expandObjects => 1,
- expandServices => 1,
- URL => $URL_TO_SERVICE
- keywords => [kw1, kw2, kw3]
- input =>{
- articleName1 => [objType1 => [ns1, ns2...]], # Simple
- articleName2 => [[objType2 => [ns3, ns4...]]], # collection of one object type
- articleName3 => [[objType3 => [ns3, ns4...]],
- [objType4 => [ns5, ns6]]], # collection of multiple object types
- }
- output =>{
- articleName1 => [objType1 => [ns1, ns2...]], # Simple
- articleName2 => [[objType2 => [ns3, ns4...]]], # collection of one object type
- articleName3 => [[objType3 => [ns3, ns4...]],
- [objType4 => [ns5, ns6]]], # collection of multiple object types
- }</pre>
+ Registry => which registry do you want to search (optional)
+ serviceName => $serviceName, (optional)
+ serviceType => $serviceType, (optional)
+ authURI => $authURI, (optional)
+ authoritative => 1, (optional)
+ category => "moby" | "cgi" | "soap" (currently only moby supported) (optional)
+ expandObjects => 1, (optional)
+ expandServices => 1, (optional)
+ URL => $URL_TO_SERVICE (optional)
+ keywords => [kw1, kw2, kw3] (optional)
+ input =>[ (optional)
+ [objType1 => [ns1, ns2...]], # Simple
+ [[objType2 => [ns3, ns4...]]], # collection of one object type
+ [[objType3 => [ns3, ns4...]],
+ [objType4 => [ns5, ns6...]]], # collection of multiple object types
+ ]
+ output =>[ (optional)
+ [objType1 => [ns1, ns2...]], # Simple
+ [[objType2 => [ns3, ns4...]]], # collection of one object type
+ [[objType3 => [ns3, ns4...]],
+ [objType4 => [ns5, ns6...]]], # collection of multiple object types
+ ]</pre>
<p>
</p>
<h2><a name="retrieveservice">retrieveService</a></h2>
<pre>
Title : retrieveService
- Usage : $WSDL = $MOBY->retrieveService(%args)
+ Usage : $WSDL = $MOBY->retrieveService($ServiceInstance)
Function : get the WSDL definition of the service with this name/authority URI
Returns : a WSDL string
- Args : authURI => $AuthURI,
- serviceName => $serviceName (as returned by the locate* calls)
- Registry => $name (as assigned in the "new" statement; default 'MOBY_Central')</pre>
+ Args : The ServiceInstance object for that service (from findService call)</pre>
<p>
</p>
<h2><a name="retrieveservicenames">retrieveServiceNames</a></h2>
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2003/06/10 23:58:26 1.32
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2003/06/11 20:36:59 1.33
@@ -262,6 +262,8 @@
foreach my $objnamepair(@{$objlistref}){
my $object = $objnamepair->[0];
my $article = $objnamepair->[1];
+ return $self->errorRegXML("Object name missing from one of your $type relationships") unless ($object);
+ $article ||="";
$message .="<objectType articleName='$article'>$object</objectType>\n";
}
$message .="</Relationship>\n";
@@ -523,7 +525,14 @@
<contactEmail>$email</contactEmail>";
if ($Category eq "moby") {
- my %SEC = %{$a{secondary}};
+ my %SEC;
+ if ($a{'secondary'} && ref($a{'secondary'} =~ /hash/i)){
+ %SEC = %{$a{secondary}}
+ } elsif ($a{'secondary'} && !(ref($a{'secondary'} =~ /hash/i))){
+ return $self->errorRegXML("invalid structure of secondary parameters. Expected hashref.")
+ }
+
+
my %funkyhash = ( Input => $a{input}, Output => $a{output});
while (my ($inout, $param) = each %funkyhash){
my $inout_lc = lc ($inout);
@@ -539,6 +548,7 @@
foreach my $article(@ALLARTICLES){
my ($articleName, $def) = @{$article};
+ $articleName ||="";
my @Objects; #
unless (ref($def) =~ /array/i){return $self->errorRegXML("invalid structure of $inout objects, expected arrayref for article $articleName")}
my @objectdefs;
@@ -694,31 +704,32 @@
=head2 findService
Title : findService
- Usage : $REG = $MOBY->findService(%args)
+ Usage : $ServiceInstances = $MOBY->findService(%args)
Function : deregister a registered MOBY Service
- Returns : MOBY::Registration object
+ Returns : arrayref of MOBY::Client::ServiceInstance objects
Args :
- serviceName => $serviceName,
- serviceType => $serviceType,
- authURI => $authURI,
- authoritative => 1,
- category => "moby" | "cgi" | "soap" (currently only moby supported)
- expandObjects => 1,
- expandServices => 1,
- URL => $URL_TO_SERVICE
- keywords => [kw1, kw2, kw3]
- input =>{
- articleName1 => [objType1 => [ns1, ns2...]], # Simple
- articleName2 => [[objType2 => [ns3, ns4...]]], # collection of one object type
- articleName3 => [[objType3 => [ns3, ns4...]],
- [objType4 => [ns5, ns6]]], # collection of multiple object types
- }
- output =>{
- articleName1 => [objType1 => [ns1, ns2...]], # Simple
- articleName2 => [[objType2 => [ns3, ns4...]]], # collection of one object type
- articleName3 => [[objType3 => [ns3, ns4...]],
- [objType4 => [ns5, ns6]]], # collection of multiple object types
- }
+ Registry => which registry do you want to search (optional)
+ serviceName => $serviceName, (optional)
+ serviceType => $serviceType, (optional)
+ authURI => $authURI, (optional)
+ authoritative => 1, (optional)
+ category => "moby" | "cgi" | "soap" (currently only moby supported) (optional)
+ expandObjects => 1, (optional)
+ expandServices => 1, (optional)
+ URL => $URL_TO_SERVICE (optional)
+ keywords => [kw1, kw2, kw3] (optional)
+ input =>[ (optional)
+ [objType1 => [ns1, ns2...]], # Simple
+ [[objType2 => [ns3, ns4...]]], # collection of one object type
+ [[objType3 => [ns3, ns4...]],
+ [objType4 => [ns5, ns6...]]], # collection of multiple object types
+ ]
+ output =>[ (optional)
+ [objType1 => [ns1, ns2...]], # Simple
+ [[objType2 => [ns3, ns4...]]], # collection of one object type
+ [[objType3 => [ns3, ns4...]],
+ [objType4 => [ns5, ns6...]]], # collection of multiple object types
+ ]
=cut
@@ -727,72 +738,82 @@
sub findService {
my ($self, %a) = @_;
+ my $reg = ($a{Registry})?$a{Registry}:$self->default_MOBY_servername;
+
my $id = $a{'serviceID'};
- my $servicename = $a{'servicename'}; $servicename |="";
- my $authoritative = $a{'authoritative'}; $authoritative |= 0;
- my $serviceType = $a{'serviceType'}; $serviceType |= "";
- my $authURI = $a{'authURI'}; $authURI |="";
- my $category = $a{'category'}; $category |= "moby" ;
- my $exObj = $a{'expandObjects'}; $exObj |=0;
- my $exServ = $a{'expandServices'}; $exServ |= 0;
- my $kw = $a{'keywords'};
+ my $servicename = $a{'servicename'}; $servicename ||="";
+ my $authoritative = $a{'authoritative'}; $authoritative ||= 0;
+ my $serviceType = $a{'serviceType'}; $serviceType ||= "";
+ my $authURI = $a{'authURI'}; $authURI ||="";
+ my $category = $a{'category'}; $category ||= "moby" ;
+ my $exObj = $a{'expandObjects'}; $exObj ||=0;
+ my $exServ = $a{'expandServices'}; $exServ ||= 0;
+ my $kw = $a{'keywords'}; $kw ||=[];
ref($kw) =~ /array/i || return $self->errorRegXML("invalid structure of keywords. Expected arrayref");
my @kw = @{$kw};
my $message = "<findService>
-<authoritative>$authoritative</authoritative>
-<Category>$category</Category>
-<serviceType>$serviceType</serviceType>
-<serviceName>$servicename</serviceName>
-<authURI>$authURI</authURI>;
-<expandObjects>$exObj</expandObjects>
-<expandServices>$exServ</expandServices>
-<keywords>\n";
+ <authoritative>$authoritative</authoritative>
+ <Category>$category</Category>
+ <serviceType>$serviceType</serviceType>
+ <serviceName>$servicename</serviceName>
+ <authURI>$authURI</authURI>;
+ <expandObjects>$exObj</expandObjects>
+ <expandServices>$exServ</expandServices>
+ <keywords>\n";
foreach (@kw){
- $message .="<keyword>$kw</keyword>\n";
+ $message .="<keyword>$kw</keyword>\n";
}
$message .="</keywords>\n";
+
+ unless (ref($a{input}) =~ /array/i){return $self->errorRegXML("invalid structure of input objects, expected arrayref for input")}
+ unless (ref($a{output}) =~ /array/i){return $self->errorRegXML("invalid structure of output objects, expected arrayref for output")}
- my %IN = %{$a{input}};
- my %OUT = %{$a{output}};
- my %funkyhash = ( Input => \%IN, Output => \%OUT);
+ my %funkyhash = ( Input => $a{input}, Output => $a{output});
+ #input =>[
+ # [objType1 => [ns1, ns2...]], # Simple
+ # [[objType2 => [ns3, ns4...]]], # collection of one object type
+ # [[objType3 => [ns3, ns4...]],
+ # [objType4 => [ns5, ns6...]]], # collection of multiple object types
+ # ]
while (my ($inout, $param) = each %funkyhash){
my $inout_lc = lc ($inout);
- my %PARAM = %{$param};
+ my @PARAM = @{$param};
$message .= "<${inout_lc}Objects><${inout}>\n";
- while (my ($articleName, $def) = each %PARAM){
- my @Objects; #
- unless (ref($def) =~ /array/i){return $self->errorRegXML("invalid structure of $inout objects, expected arrayref for article $articleName")}
+ foreach my $param(@PARAM){
+ unless (ref($param) =~ /array/i){return $self->errorRegXML("invalid structure of $inout objects, expected arrayref of class and \@namespaces")}
+ my ($class, $namespaces) = @{$param};
my @objectdefs;
- if ((ref $def->[0]) =~ /array/i){ # collection
- # def= [[objType2 => [ns3, ns4...]], ...]
+ if ((ref $class) =~ /array/i){ # collection
$message .="<Collection>\n";
- @objectdefs = @{$def};
+ @objectdefs = $class;
} else { # Nipple
- @objectdefs = ($def);
- # def = [objType1 => [ns1, ns2...]],
+ @objectdefs = ($param);
}
foreach my $objectdef(@objectdefs){
- $message .="<Simple articleName='$articleName'>\n";
+ $message .="<Simple>\n";
my ($type, $Namespaces) = @{$objectdef};
$message .="<objectType>$type</objectType>\n";
- unless (ref($Namespaces) =~ /array/i){return $self->errorRegXML("invalid structure of $inout namespaces for object $type in article $articleName; expected arrayref")}
+ unless (ref($Namespaces) =~ /array/i){return $self->errorRegXML("invalid structure of $inout namespaces for object $type; expected arrayref")}
foreach my $ns(@{$Namespaces}){
$message .="<Namespace>$ns</Namespace>\n";
}
$message .="</Simple>\n";
}
- if ((ref($def->[0])) =~ /array/i){
+ if ((ref($class)) =~ /array/i){
$message .="</Collection>\n";
}
}
$message .= "</${inout}></${inout_lc}Objects>\n";
}
$message .= "</findService>\n";
+
+# print $message;
+# my $return = $self->SOAP_connection($reg)->call('retrieveServiceTypes' => (@_))->paramsall;
- my $return = $self->SOAP_connection->call(findService => ($message))->paramsall;
- return ($self->parseRegXML($return));
+ my $return = $self->SOAP_connection($reg)->call('findService' => ($message))->paramsall;
+ return ($self->_parseServices($reg, $return));
}
@@ -800,33 +821,31 @@
=head2 retrieveService
Title : retrieveService
- Usage : $WSDL = $MOBY->retrieveService(%args)
+ Usage : $WSDL = $MOBY->retrieveService($ServiceInstance)
Function : get the WSDL definition of the service with this name/authority URI
Returns : a WSDL string
- Args : authURI => $AuthURI,
- serviceName => $serviceName (as returned by the locate* calls)
- Registry => $name (as assigned in the "new" statement; default 'MOBY_Central')
-
+ Args : The ServiceInstance object for that service (from findService call)
=cut
sub retrieveService {
- my ($self, %a)=@_;
+ my ($self, $SI)=@_;
+ return undef unless $SI && $SI->isa('MOBY::Client::ServiceInstance');
- my $auth = $a{authURI};
- my $name = $a{serviceName};
- my $reg = ($a{Registry})?$a{Registry}:$self->default_MOBY_servername;
+ my $auth = $SI->authority;
+ my $name = $SI->name;
+ my $reg = $SI->registry;
return undef unless ($auth && $name && $self->SOAP_connection($reg));
my $message = "
<retrieveService>
- <Service authURI='$auth' serviceName='$name'/>
+ ".($SI->XML)."
</retrieveService>";
- my $conn =
+
my $return = $self->SOAP_connection($reg)->call(retrieveService => ($message))->paramsall;
my $parser = new XML::DOM::Parser;
my $doc = $parser->parse($return);
@@ -1235,10 +1254,11 @@
output => $Output,
description => $Description,
registry => $Registry,
+ XML => $Service->toString,
);
push @Services, $Instance;
}
- return @Services;
+ return \@Services;
}
sub parseRegXML {
@@ -1278,7 +1298,7 @@
# regardless of their depth!!
my ($DOM, $node) = @_;
my $x = $DOM->getElementsByTagName($node);
- unless ($x->item(0)){print "no child nodes for $node in \n",$DOM->toString,"\n"};
+ unless ($x->item(0)){return};
my @child = $x->item(0)->getChildNodes;
my $content;
foreach (@child){
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Service.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Service.html 2003/06/05 19:08:19 1.1
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Service.html 2003/06/11 20:36:59 1.2
@@ -77,10 +77,30 @@
<h2><a name="execute">execute</a></h2>
<pre>
Title : execute
- Usage : $result = $Service->execute(@params)
+ Usage : $result = $Service->execute(%args)
Function : execute the MOBY service
Returns : whatever the Service provides as output
- Args : whatever the Service requires as input</pre>
+ Args : XMLinputlist => \@data
+ Comment : @data is a list of single invocation inputs; the XML goes between the
+ <queryInput> tags of a servce invocation XML.
+ Each element of @data is itself a listref of [articleName, $XML].
+ articleName may be undef if it isn't required.
+ $XML is the actual XML of the Input object
+ Examples : $Service->execute(XMLinputlist => [
+ ['object1', '<Object namespace="blah" id="123">'],
+ ['object1', '<Object namespace="blah" id="234">']
+ ]);
+ This would invoke the service twice (in a single message)
+ the first time with an object "123" and the second time with object "234". the
+ input is named "object1" in both cases.
+
+ $Service->execute(XMLinputlist => [
+ ['collection1', [
+ '<Object namespace="blah" id="123">',
+ '<Object namespace="blah" id="234">']
+ ]);
+ This would invoke the service once with a collection of sequence inputs
+ called "collection1"</pre>
<p>
</p>
<h2><a name="servicename">ServiceName</a></h2>
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Service.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Service.pm 2003/03/01 18:06:54 1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Service.pm 2003/06/11 20:36:59 1.4
@@ -142,19 +142,65 @@
=head2 execute
Title : execute
- Usage : $result = $Service->execute(@params)
+ Usage : $result = $Service->execute(%args)
Function : execute the MOBY service
Returns : whatever the Service provides as output
- Args : whatever the Service requires as input
+ Args : XMLinputlist => \@data
+ Comment : @data is a list of single invocation inputs; the XML goes between the
+ <queryInput> tags of a servce invocation XML.
+ Each element of @data is itself a listref of [articleName, $XML].
+ articleName may be undef if it isn't required.
+ $XML is the actual XML of the Input object
+ Examples : $Service->execute(XMLinputlist => [
+ ['object1', '<Object namespace="blah" id="123">'],
+ ['object1', '<Object namespace="blah" id="234">']
+ ]);
+ This would invoke the service twice (in a single message)
+ the first time with an object "123" and the second time with object "234". the
+ input is named "object1" in both cases.
+
+ $Service->execute(XMLinputlist => [
+ ['collection1', [
+ '<Object namespace="blah" id="123">',
+ '<Object namespace="blah" id="234">']
+ ]);
+ This would invoke the service once with a collection of sequence inputs
+ called "collection1"
+
=cut
sub execute {
- my ($self, @params) = @_;
+ my ($self, %args) = @_;
+ return "ERROR: expected listref for XMLinputlist" unless (ref($args{XMLinputlist}) =~ /array/i);
+ my @inputs = @{$args{XMLinputlist}};
+ my $data;
+ foreach (@inputs){
+ return "ERROR: expected listref [articleName, XML] for data element" unless (ref($_) =~ /array/i);
+ my ($articleName, $XML) = @{$_};
+ if (!(ref($XML)=~/array/i)){
+ $articleName ||="";
+ $XML ||= "";
+ $data .= "<moby:queryInput moby:articleName='$articleName'><moby:Simple>\n$XML\n</moby:Simple></moby:queryInput>\n";
+ } elsif (ref($XML)=~/array/i){
+ my @objs = @{$XML};
+ $data .="<moby:queryInput moby:articleName='$articleName'><moby:Collection>\n";
+ foreach (@objs){
+ $data .= "$_\n";
+ }
+ $data .="</moby:Collection>\n</moby:queryInput>\n"
+ }
+ }
+ $data = "<![CDATA[<?xml version='1.0' encoding='UTF-8'?>
+ <moby:MOBY xmlns:moby='http://www.biomoby.org/moby-s'>
+ <moby:Query>
+ $data
+ </moby:Query>
+ </moby:MOBY>]]>";
my $METHOD = $self->ServiceName;
- &_LOG(@params, $METHOD);
- return $self->_soapService->$METHOD(@params);
+ &_LOG(%args, $METHOD);
+ return $self->_soapService->$METHOD($data);
}
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.html 2003/06/05 19:08:19 1.1
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.html 2003/06/11 20:36:59 1.2
@@ -48,7 +48,9 @@
type => 'Retrieve',
category => 'moby',
output => 'Sequence',
- description => 'retrieves random sequences from a database');</pre>
+ description => 'retrieves random sequences from a database',
+ XML => $xml, # the XML from MOBY::Central::findService
+ );</pre>
<p>
</p>
<hr />
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2003/03/05 15:29:20 1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2003/06/11 20:36:59 1.4
@@ -22,7 +22,9 @@
type => 'Retrieve',
category => 'moby',
output => 'Sequence',
- description => 'retrieves random sequences from a database');
+ description => 'retrieves random sequences from a database',
+ XML => $xml, # the XML from MOBY::Central::findService
+ );
=cut
@@ -136,6 +138,7 @@
category => [undef, 'read/write'],
description => [undef, 'read/write'],
registry => ['MOBY_Central', 'read/write'],
+ XML => [undef, 'read/write'],
);
#_____________________________________________________________
More information about the MOBY-guts
mailing list