blib/lib/MOBY/Central.pm

filter: Statementstmt 86.6% 13 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 90.0% 18 / 20 CC 1 SCAR 0.6
CC
1
Cov
87%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/MOBY/MobyXMLConstants.pm ↑ Summary blib/lib/MOBY/OntologyServer.pm »
1 #$Id: Central.pm,v 1.13 2010/05/03 18:34:40 kawas Exp $
2  
3 =head1 NAME
4  
5 MOBY::Central.pm - API for communicating with the MOBY Central registry
6  
7 =cut
8  
9 package MOBY::Central;
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use vars qw($AUTOLOAD $WSDL_TEMPLATE $WSDL_POST_TEMPLATE $WSDL_ASYNC_TEMPLATE $WSDL_ASYNC_POST_TEMPLATE);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 0 ▶use MOBY::OntologyServer;
Subroutine BEGIN: called CC=1 SCAR=2.6
15 use MOBY::service_type;
16 use MOBY::authority;
17 use MOBY::service_instance;
18 use MOBY::simple_input;
19 use MOBY::simple_output;
20 use MOBY::collection_input;
21 use MOBY::collection_output;
22 use MOBY::secondary_input;
23 use MOBY::central_db_connection;
24 use MOBY::Config;
25 use MOBY::RDF::Ontologies::Services;
26 use URI;
27 use LWP;
28 use MOBY::CommonSubs;
29  
30 use vars qw /$VERSION/;
31 $VERSION = sprintf "%d.%02d", q$Revision: 1.13 $ =~ /: (\d+)\.(\d+)/;
32  
33 use Encode;
34  
35 use MOBY::MobyXMLConstants;
36 my $debug = 0;
37 my $listener = 1;
38  
39 my %user_agent_args = (agent => "MOBY-Central-Perl");
40  
41 if ($debug) {
42 open( OUT, ">/tmp/CentralRegistryLogOut.txt" ) || die "cant open logfile\n";
43 print OUT "created logfile\n";
44 close OUT;
45 }
46  
47  
48 if ($listener) {
49 eval {open(OUT, ">>/tmp/CentralRegistryListener.txt")};
50 $listener = 0 if @!; # abort listening if the logging attempt failed
51 }
52  
53 sub listener {
54 return unless $listener;
55 my (%args) = @_;
56 my $authority = $args{authority};
57 my $servicename = $args{servicename};
58 my $ip = $ENV{REMOTE_ADDR}; # ="137.82.67.190"
59 open(OUT, ">>/tmp/CentralRegistryListener.txt");
60 use Time::localtime;
61 my $time = ctime;
62 print OUT "$time\t$ip\t$authority\t$servicename\n";
63 close OUT;
64 }
65  
66
67 =head1 SYNOPSIS
68  
69 REQUIRES MYSQL 3.23 or later!!!!
70  
71 If you are a Perl user, you should be using the
72 MOBY::Client:Central module to talk to MOBY-Central
73  
74 If you need to connect directly, here is how it
75 is done in perl 5.6 and 5.6.1. It wont work
76 in Perl 5.8... sorry. Look how MOBY::Client::Cent
77 does it if you want to use Perl 5.8
78  
79  
80 --------------------------------------
81 SERVER-SIDE
82  
83 use SOAP::Transport::HTTP;
84  
85 my $x = new SOAP::Transport::HTTP::CGI;
86 # fill in your server path below...
87 $x->dispatch_to('WWW_SERVER_PATH', 'MOBY::Central');
88 $x->handle;
89  
90  
91 ---------------------------------------
92  
93 CLIENT-SIDE
94  
95 use SOAP::Lite +autodispatch =>
96 proxy => 'http://moby.ucalgary.ca/moby/MOBY-Central.pl', # or whatever...
97 on_fault => sub {
98 my($soap, $res) = @_;
99 die ref $res ? $res->faultstring : $soap->transport->status, "\n";
100 };
101  
102 my $NAMES_XML = MOBY::Central->retrieveObjectNames;
103 print $NAMES_XML;
104 # ... do something with the XML
105  
106 ----------------------------------------
107  
108  
109 =head1 DESCRIPTION
110  
111 Used to do various transactions with MOBY-Central registry, including registering
112 new Object and Service types, querying for these types, registering new
113 Servers/Services, or queryiong for available services given certain input/output
114 or service type constraints.
115  
116 =cut
117  
118 =head1 CONFIGURATION
119  
120 This depends on a config file to get its database connection information. At a minimum
121 this config file must have the following clause:
122  
123 [mobycentral]
124 url = some.url
125 username = foo
126 password = bar
127 port = portnumber
128 dbname = mobycentral
129  
130  
131 The space before and after the '=' is critical.
132  
133 The end of a clause is indicated by a blank line.
134  
135 Additional identically formatted clauses may be added for each of:
136  
137 [mobyobject]
138 [mobynamespace]
139 [mobyservice]
140 [mobyrelationship]
141  
142 if these ontologies are being served from a local database (via the
143 OntologyServer module). These clauses will be read by the OntologyServer
144 module if they are present, otherwise default connections will be made
145 to the MOBY Central ontology server.
146  
147 The config file must be readable by the webserver, and the webserver
148 environment should include the following ENV variable:
149  
150 $ENV{MOBY_CENTRAL_CONFIG} = /path/to/config/file.name
151  
152  
153 =head1 AUTHORS
154  
155 Mark Wilkinson (markw@illuminae.com)
156  
157 BioMOBY Project: http://www.biomoby.org
158  
159 =cut
160  
161 =head1 Registration XML Object
162  
163 This is sent back to you for all registration and
164 deregistration calls
165  
166 <MOBYRegistration>
167 <success>$success</success>
168 <id>$id</id>
169 <message><![CDATA[$message]]></message>
170 </MOBYRegistration>
171  
172  
173 success is a boolean indicating a
174 successful or a failed registration
175  
176 id is the deregistration ID of your registered
177 object or service to use in a deregister call.
178  
179 message will contain any additional information
180 such as the reason for failure.
181  
182  
183 =cut
184  
185 sub Registration {
186 my ($details) = @_;
187 my $id = $details->{id};
188 my $success = $details->{success};
189 my $message = $details->{message};
190 my $RDF = $details->{RDF};
191  
192 # return "<MOBYRegistration>
193 # <id>$id</id>
194 # <success>$success</success>
195 # <message><![CDATA[$message]]></message>
196 # <RDF><![CDATA[$RDF]]></RDF>
197 # </MOBYRegistration>";
198 return "<MOBYRegistration>
199 <id>$id</id>
200 <success>$success</success>
201 <message><![CDATA[$message]]></message>
202 <RDF>$RDF</RDF>
203 </MOBYRegistration>";
204 }
205 =cut
206  
207  
208  
209  
210  
211  
212  
213 =head1 METHODS
214  
215  
216  
217 =head2 new
218  
219 Title : new
220 Usage : deprecated
221  
222 =cut
223  
224 sub new {
225 my ( $caller, %args ) = @_;
226 print STDERR "\nuse of MOBY::Central->new is deprecated\n";
227 return 0;
228 }
229  
230 =head2 registerObjectClass
231  
232 The registerObjectClass call is:
233  
234 =over 3
235  
236 =item * used to register a new object Class into the Class ontology
237  
238 =item * can envision this as simply registering a new node into the Class ontology graph, and creating the primary connections from that node.
239  
240 =item * MOBY, by default, supports three types of Class Relationships: ISA, HAS, and HASA (these are the relationship ontology terms)
241  
242 =over 3
243  
244 =item * Foo ISA bar is a straight inheritence, where all attributes of bar are guaranteed to be present in foo.
245  
246 =item * foo HAS bar is a container type, where bar is an object inside of foo in one or more copies.
247  
248 =item * foo HASA bar is a container type, where bar is an object inside of foo in one copy only
249  
250 =back
251  
252 =item * notice that, in a HAS and HASA relationships, it is necessary to indicate an article name for each contained object type. Thus, for example, you could have a sequence object that contained a String object with name "nucleotideSequence" and an Integer object with the name "sequenceLength".
253  
254 =back
255  
256 Input XML :
257  
258 <registerObjectClass>
259 <objectType>NewObjectType</objectType>
260 <Description><![CDATA[
261 human readable description
262 of data type]]>
263 </Description>
264 <Relationship relationshipType="RelationshipOntologyTerm">
265 <objectType articleName="SomeName">ExistingObjectType</objectType>
266 ...
267 ...
268 </Relationship>
269 ...
270 ...
271 <authURI>Your.URI.here</authURI>
272 <contactEmail>You@your.address.com</contactEmail>
273 </registerObjectClass>
274  
275  
276 Output XML :
277  
278 ...Registration Object...
279  
280  
281 =cut
282  
283 sub registerObjectClass {
284  
285 # this contacts the ontology server to register
286 # the ontology and writes the resulting URI into
287 # the MOBY Central database
288 my ( $pkg, $payload ) = @_;
289 my ( $success, $message );
290 my $OntologyServer = &_getOntologyServer( ontology => 'object' );
291 my $RelOntologyServer = &_getOntologyServer( ontology => 'relationship' );
292 my ( $term, $desc, $relationships, $email, $auth, $clobber ) =
293 &_registerObjectPayload($payload);
294  
295 unless ( defined $term && defined $desc && defined $auth && defined $email )
296 {
297 if ( $term =~ /FAILED/ ) { return &_error( "Malformed XML;", "" ); }
298 return &_error("Malformed XML; may be missing required parameters objectType, Description, authURI or contactEmail",
299 ""
300 );
301 }
302 #print STDERR "$term, $desc, $auth, $email\n";
303 #check encoding
304 unless ( decode_utf8($term) eq $term && decode_utf8($desc) eq $desc && decode_utf8($auth) eq $auth && decode_utf8($email) eq $email )
305 {
306 return &_error("Invalid character encoding; one or all of objectType, Description, authURI or contactEmail were not UTF-8 encoded.",
307 ""
308 );
309 }
310 return &_error( "Malformed authURI - must not have an http:// prefix", "" )
311 if $auth =~ '[/:]';
312 return &_error( "Malformed authURI - must take the form NNN.NNN.NNN", "" )
313 unless $auth =~ /\./;
314 return &_error("Malformed email - must be a valid email address of the form name\@organization.foo",
315 ""
316 )
317 unless $email =~ /\S\@\S+\.\S+/;
318 return &_error("Object name may not contain spaces or other characters invalid in a URN",
319 ""
320 )
321 if $term =~ /[\/\'\\\s"\&\<\>\[\]\^\`\{\|\}:\~%\!\@#\$\*\+=]/;
322 if ( $term =~ m"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?" )
323 { # matches a URI
324 return &_error( "Object name may not be an URN or URI", "" ) if $1;
325 }
326 my $ISAs;
327  
328 # validate that the final ontology will be valid by testing against existing relationships and such
329 while ( my ( $reltype, $obj ) = each %{$relationships} ) {
330 my ( $success, $message, $URI ) =
331 $RelOntologyServer->relationshipExists(
332 term => $reltype,
333 ontology => 'object'
334 ); # success = 1 if it does
335 ($success == 0) && return &_error( $message, $URI );
336 foreach ( @{$obj} ) {
337 ++$ISAs if ( $URI =~ /isa$/i );
338 my ( $objectType, $articleName ) = @{$_};
339 return &_error("Object contains a child relationship with an invalid articlename. Articlenames name may not contain spaces or other special characters.","")
340 if $articleName =~ /([\+\=\':\s\"\&\<\>\[\]\^\`\{\|\}\~\(\)\\\/\$\#\@\,\|\?\.!\*\;])/;
341
342 my ( $success, $message, $URI ) =
343 $OntologyServer->objectExists( term => $objectType )
344 ; # success = 1 if it does
345 ($success == 0) && return &_error( $message, $URI );
346 }
347 }
348 return &_error(
349 "Object must have exactly one ISA parent in the MOBY Object ontology")
350 unless $ISAs == 1;
351 $clobber = defined($clobber) ? $clobber : 0;
352 $clobber = 0
353 unless ( $clobber eq 0 || $clobber eq 1 || $clobber eq 2 ); # safety!
354 my ( $exists, $exists_message, $URI ) =
355 $OntologyServer->objectExists( term => $term ); # success = 1 if it does
356 ( ( $exists == 1 && !$clobber )
357 && return &_error( "Object $term already exists", $URI ) );
358 $clobber = 0
359 unless ($exists)
360 ; # it makes no sense to clobber something that doesnt' exist
361 if ($exists) {
362  
363 if ( $clobber == 1 ) {
364 my ( $success, $message ) =
365 $OntologyServer->deprecateObject( term => $term );
366 ($success == 0) && return &_error( $message, $URI );
367 }
368 elsif ( $clobber == 2 ) {
369 my ( $success, $message ) =
370 $OntologyServer->deleteObject( term => $term );
371 ($success == 0) && return &_error( $message, $URI );
372 }
373 }
374  
375 # now test if the object inherits from primitives... if so, abort
376 if ( keys %{$relationships} ) {
377 while ( my ( $reltype, $obj ) = each %{$relationships} ) {
378 next unless ($reltype =~ /isa/i); # we are only testing isa relationships here.
379 foreach ( @{$obj} ) {
380 my ( $objectType, $articleName ) = @{$_};
381 if (&_testObjectTypeAgainstPrimitives($objectType)){
382 return &_error( "Inheritance from Primitive data-types is now deprecated. You shold construct your object using a HASA relationship. for example, text-plain HASA string (as opposed to ISA string)", "" );
383 }
384 }
385 }
386 }
387 # are the article names unique?
388 if ( keys %{$relationships} ) {
389 my $parent_type;
390 my %art_names = ();
391 while ( my ( $reltype, $obj ) = each %{$relationships} ) {
392 # one isa relationship
393 if ($reltype =~ /isa/i) {
394 foreach ( @{$obj} ) {
395 my ( $objectType, $articleName ) = @{$_};
396 $parent_type = $objectType;
397 }
398 } else {
399 #has/hasa relationship
400 foreach ( @{$obj} ) {
401 my ( $objectType, $articleName ) = @{$_};
402 return return &_error( "Article names for HAS/HASA relationships must be unique. Please ensure that names are unique!", "" )
403 if $art_names{$articleName};
404 # add name to the hash
405 $art_names{$articleName} = 1;
406 }
407 }
408 }
409 unless (&_extract_terms($parent_type, \%art_names)){
410 return &_error( "Article names for HAS/HASA relationships (including those inherited) must be unique. Please ensure that names are unique!", "" );
411 }
412 }
413  
414 # should be good to go now...
415  
416 ( $success, $message, $URI ) = $OntologyServer->createObject(
417 node => $term,
418 description => $desc,
419 authority => $auth,
420 contact_email => $email
421 );
422 ($success == 0) && return &_error( $message, $URI );
423 my @failures;
424 my $messages = "";
425 if ( keys %{$relationships} ) { # need to pull them out with ISA's first
426 foreach my $reltype(qw{ISA HASA HAS}){
427 my ( $obj ) = $relationships->{$reltype};
428 foreach ( @{$obj} ) {
429 my ( $objectType, $articleName ) = @{$_};
430 my ( $success, $message ) =
431 $OntologyServer->addObjectRelationship(
432 subject_node => $term,
433 relationship => $reltype,
434 object_node => $objectType,
435 articleName => $articleName,
436 authority => $auth,
437 contact_email => $email
438 );
439 unless ($success){
440 push @failures, $objectType;
441 $messages .= $message."; ";
442 }
443 }
444 }
445 }
446 if ( scalar(@failures) ) {
447 my ( $success, $message, $deleteURI ) =
448 $OntologyServer->deleteObject( term => $term )
449 ; # hopefully this situation will never happen!
450 ($success == 0) && return &_error(
451 "object failed ISA and/or HASA connections,
452 and subsequently failed deletion. This is a critical error,
453 and may indicate corruption of the MOBY Central registry.", $deleteURI
454 );
455 return &_error("object failed to register due to failure during registration of ISA/HASA relationships. Message returned was $messages"
456 . ( join ",", (@failures) ) . "\n",
457 ""
458 );
459 }
460 return &_success( "Object $term registered successfully.", $URI );
461 }
462  
463 ###############################
464 #
465 ###############################
466  
467 sub _extract_terms {
468  
469 my ( $datatype, $articles ) = @_;
470 my $ont_serv = MOBY::OntologyServer->new( ontology => "object" );
471 my $stuff = $ont_serv->retrieveObject( type => $datatype );
472 return 1 unless $stuff;
473  
474 # extract all isa/hasa/has relationships
475 my $rels = $stuff->{Relationships} if defined $stuff->{Relationships};
476 for my $relation ( keys %{$rels} ) {
477 for my $term ( @{ $rels->{$relation} } ) {
478  
479 # pos 1 has articlename, pos 2 has datatype
480 # if we are in isa, then drill into it
481 if ( $relation =~ m/\:isa$/i ) {
482 return 0 unless &_extract_terms( @{$term}[2], $articles );
483 } else {
484  
485 # check if we already processed the articlename ...
486 return 0 if defined @{$term}[1] and $articles->{ @{$term}[1] };
487 $articles->{ @{$term}[1] } = 1 if @{$term}[1];
488 }
489 }
490 }
491 return 1;
492 }
493  
494 #Eddie - converted
495 sub _registerObjectPayload {
496 my ($payload) = @_; #EDDIE - assuming that payload is a string
497 my $Parser = XML::LibXML->new();
498 my $doc = $Parser->parse_string($payload);
499 my $Object = $doc->documentElement();
500 my $obj = $Object->nodeName;
501 return undef unless ( $obj eq 'registerObjectClass' );
502 my $term = &_nodeTextContent( $Object, "objectType" );
503 my $desc = &_nodeCDATAContent( $Object, "Description" );
504 my $authURI = &_nodeTextContent( $Object, "authURI" );
505 my $email = &_nodeTextContent( $Object, "contactEmail" );
506 my $clobber = &_nodeTextContent( $Object, "Clobber" );
507  
508 #my @ISA = &_nodeArrayContent($Object, "ISA");
509 #my @HASA = &_nodeArrayExtraContent($Object, "HASA","articleName");
510 my %att_value;
511 my %relationships;
512 my $x = $doc->getElementsByTagName("Relationship");
513 my $no_relationships = $x->size;
514 for ( my $n = 1 ; $n <= $no_relationships ; ++$n ) {
515 my $relationshipType =
516 $x->get_node($n)->getAttributeNode('relationshipType')
517 ; # may or may not have a name
518 if ($relationshipType) {
519 $relationshipType = $relationshipType->getValue();
520 }
521 else {
522 return
523 "FAILED! must include a relationshipType in every relationship\n";
524 }
525 my @child = $x->get_node($n)->childNodes;
526 foreach (@child) {
527 next unless $_->nodeType == ELEMENT_NODE;
528 my $article =
529 $_->getAttributeNode('articleName'); # may or may not have a name
530 if ($article) { $article = $article->getValue() }
531 my @child2 = $_->childNodes;
532 foreach (@child2) {
533  
534 #print getNodeTypeName($_), "\t", $_->toString,"\n";
535 next unless $_->nodeType == TEXT_NODE;
536 push @{ $relationships{$relationshipType} },
537 [ $_->toString, $article ];
538 }
539 }
540 }
541 return ( $term, $desc, \%relationships, $email, $authURI, $clobber );
542 }
543  
544 sub _testObjectTypeAgainstPrimitives{
545 # THIS SUBROUTINE NEEDS TO BE REMOVED AND PLACED INTO THE ONTOLOGY SERVER
546 # one day when MOBY Central and the ontologies are separated properly
547 my ($type) = @_;
548 my $OS = MOBY::OntologyServer->new(ontology => 'object');
549 # get the inputlsid
550 my ($success, $desc, $inputlsid) = $OS->objectExists(term => $type);
551  
552 my $CONF = MOBY::Config->new;
553 my @primitives = @{$CONF->primitive_datatypes}; # get the list of known primitive datatypes
554 my $x = 0; # set flag down
555 # convert everything to an LSID first
556
557 my @primitive_lsids = map{my ($s, $d, $l) = $OS->objectExists(term => $_); $l} @primitives;
558
559 map {($x=1) if ($inputlsid eq $_)} @primitive_lsids; # test primitives against this one
560  
561 my $OSrel = MOBY::OntologyServer->new(ontology => 'relationship');
562 my ($exists1, $desc2, $isalsid) = $OSrel->relationshipExists(term => 'isa', ontology => 'object');
563
564 my $relationships = $OS->Relationships(
565 ontology => 'object',
566 term => $type,
567 relationship => $isalsid,
568 direction => 'root',
569 expand => 1);
570 #relationships{relationship} = [[lsid1,articleNmae], [lsid2, articleName], [lsid3, articleName]]
571 my ($isa) = keys(%$relationships); # can only be one key returned, and must be isa in this case
572 my @ISAlist;
573 (@ISAlist = @{$relationships->{$isa}}) if ($relationships->{$isa}) ;
574 # for each of the inherited parents, check their articleNames
575 foreach my $ISA(@ISAlist){ # $ISA = [lsid, articleName] (but articleName shuld be null anyway in this case)
576 my $what_it_is = $ISA->{lsid};
577 # my $articleName = $ISA->{articleName}
578 map {($x=1) if ($what_it_is eq $_)} @primitive_lsids; # test primitives against this one
579 }
580 return $x; # return flag state
581 }
582  
583  
584  
585 =head2 deregisterObjectClass
586  
587 =over 3
588  
589 =item * used to remove an Object Class from the Class ontology
590  
591 =item * this will not be successful until you respond positively to an email sent to the address that you provided when registering that object.
592  
593 =item * you may only deregister Classes that you yourself registered!
594  
595 =item * you may not deregister Object Classes that are being used as input or output by ANY service
596  
597 =item * you may not deregister Object Classes that are in a ISA or HASA relationship to any other Object Class.
598  
599 =back
600  
601  
602 Input XML :
603  
604 <deregisterObjectClass>
605 <objectType>ObjectOntologyTerm</objectType>
606 </deregisterObjectClass>
607  
608 Ouptut XML :
609  
610 ...Registration Object...
611  
612 =cut
613  
614 sub deregisterObjectClass {
615 $CONFIG ||= MOBY::Config->new; # exported by Config.pm
616 my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
617  
618 my ( $pkg, $payload ) = @_;
619 my $OntologyServer = &_getOntologyServer( ontology => 'object' );
620 return &_error( "Message Format Incorrect", "" ) unless ($payload);
621 my ($class) = &_deregisterObjectPayload($payload);
622 $debug && &_LOG("deregister object type $class\n");
623 return &_error( "Must include class of object to deregister", "" )
624 unless ($class);
625 my ( $success, $message, $existingURI ) =
626 $OntologyServer->objectExists( term => $class );
627 return &_error( "Object class $class does not exist", "" )
628 unless ($existingURI);
629  
630 my $errormsg = $adaptor->check_object_usage(type => $existingURI);
631 return &_error(
632 "Object class $class is used by a service and may not be deregistered",
633 ""
634 )
635 if ($errormsg);
636
637 my ( $success2, $message2, $URI ) =
638 $OntologyServer->deleteObject( term => $class );
639 ($success2 == 0) && return &_error( $message2, $URI );
640 return &_success( $message2, $URI );
641 }
642  
643 #Eddie - converted
644 sub _deregisterObjectPayload {
645 my ($payload) = @_;
646 my $Parser = XML::LibXML->new();
647 my $doc = $Parser->parse_string($payload);
648 my $Object = $doc->getDocumentElement();
649 my $obj = $Object->nodeName;
650 return undef unless ( $obj eq 'deregisterObjectClass' );
651 return &_nodeTextContent( $Object, "objectType" );
652 }
653  
654 =head2 registerServiceType
655  
656 =over 3
657  
658  
659 =item * used to register a new node in the Service Ontology
660  
661 =item * the ISA ontology terms must exist or this registration will fail.
662  
663 =item * all parameters are required.
664  
665 =item * email must be valid for later deregistration or updates
666  
667 =back
668  
669  
670 Input XML :
671  
672 <registerServiceType>
673 <serviceType>NewServiceType</serviceType>
674 <contactEmail>your_name@contact.address.com</contactEmail>
675 <authURI>Your.URI.here</authURI>
676 <Description>
677 <![CDATA[ human description of service type here]]>
678 </Description>
679 <Relationship relationshipType="RelationshipOntologyTerm">
680 <serviceType>ExistingServiceType</serviceType>
681 <serviceType>ExistingServiceType</serviceType>
682 </Relationship>
683 <Relationship relationshipType="AnotherRelationship">
684 ....
685 </Relationship>
686 </registerServiceType>
687  
688  
689 Output XML :
690  
691 ...Registration Object...
692  
693 =cut
694  
695 sub registerServiceType {
696  
697 # this contacts the ontology server to register
698 # the ontology and writes the resulting URI into
699 # the MOBY Central database
700 my ( $pkg, $payload ) = @_;
701 my ( $success, $message, $URI );
702 my $OntologyServer = &_getOntologyServer( ontology => 'service' );
703 $debug
704 && &_LOG(
705 "\n\npayload\n**********************\n$payload\n***********************\n\n"
706 );
707 my ( $term, $desc, $relationships, $email, $auth ) =
708 &_registerServiceTypePayload($payload);
709 $debug
710 && &_LOG(
711 "\n\nterm $term\ndesc $desc\nrel $relationships\nemail $email\nauth $auth"
712 );
713 unless ( defined $term && defined $desc && defined $auth && defined $email )
714 {
715  
716 if ( $term =~ /FAILED/ ) {
717 return &_error( "Malformed XML\n $term", "" );
718 }
719 return &_error(
720 "Malformed XML\n may be missing required parameters serviceType, Description, authURI or contactEmail",
721 ""
722 );
723 }
724 #check character encoding
725 unless ( decode_utf8( $term ) eq $term && decode_utf8( $desc ) eq $desc && decode_utf8( $auth ) eq $auth && decode_utf8( $email ) eq $email )
726 {
727 return &_error(
728 "Invalid character encoding\n One of serviceType, Description, authURI or contactEmail were not UTF-8 encoded.",
729 ""
730 );
731 }
732  
733 return &_error( "Malformed authURI - must not have an http:// prefix", "" )
734 if $auth =~ '[/:]';
735 return &_error( "Malformed authURI - must take the form NNN.NNN.NNN", "" )
736 unless $auth =~ /\./;
737 return &_error(
738 "Malformed email - must be a valid email address of the form name\@organization.foo",
739 ""
740 )
741 unless $email =~ /\S\@\S+\.\S+/;
742 return &_error("serviceType name may not contain spaces or other characters invalid in a URN",
743 ""
744 )
745 if $term =~ /[\/\'\\\s"\&\<\>\[\]\^\`\{\|\}\~%\!\@#\$\*\+=:]/;
746  
747 # validate that the final ontology will be valid
748 my ( $exists, $exists_message, $existingURI ) =
749 $OntologyServer->serviceExists( term => $term ); # success = 1 if it does
750 ( ( $exists == 1 )
751 && return &_error( "Service type $term already exists", $existingURI )
752 );
753  
754 # is the relationship valid?
755 my $OSrel = MOBY::OntologyServer->new( ontology => 'relationship' );
756 if ( keys %{$relationships} ) {
757 while ( my ( $reltype, $obj ) = each %{$relationships} ) {
758 my ( $success, $desc, $URI ) = $OSrel->relationshipExists(
759 term => $reltype,
760 ontology => 'service'
761 );
762 ( !$success ) && return &_error(
763 "Relationship type $reltype does not exist in the relationship ontology",
764 ""
765 );
766 }
767 }
768  
769 # are the predicate service types valid?
770 my $OSsrv = MOBY::OntologyServer->new( ontology => 'service' );
771 if ( keys %{$relationships} ) {
772 while ( my ( $srvtype, $svcs ) = each %{$relationships} ) {
773 foreach my $svc ( @{$svcs} ) {
774 my ( $success, $desc, $URI ) =
775 $OSsrv->serviceExists( term => $svc );
776 ( !$success ) && return &_error(
777 "Service type $srvtype does not exist in the service ontology",
778 ""
779 );
780 }
781 }
782 }
783  
784 # hunky dorey. Now register!
785 ( $success, $message, $URI ) = $OntologyServer->createServiceType(
786 node => $term,
787 description => $desc,
788 authority => $auth,
789 contact_email => $email
790 );
791 ($success == 0) && return &_error( $message, $URI );
792 my @failures;
793 if ( keys %{$relationships} ) {
794 while ( my ( $reltype, $obj ) = each %{$relationships} ) {
795 foreach my $serviceType ( @{$obj} ) {
796 my ( $success, $message ) =
797 $OntologyServer->addServiceRelationship(
798 subject_node => $term,
799 relationship => $reltype,
800 object_node => $serviceType,
801 authority => $auth,
802 contact_email => $email
803 );
804 ($success == 0) && push @failures, $serviceType;
805 }
806 }
807 }
808 if ( scalar(@failures) ) {
809 my ( $success, $message, $deleteURI ) =
810 $OntologyServer->deleteServiceType( term => $term )
811 ; # hopefully this situation will never happen!
812 ($success == 0) && return &_error(
813 "Service registration failed ISA connections,
814 and subsequently failed deletion. This is a critical error,
815 and may indicate corruption of the MOBY Central registry", $deleteURI
816 );
817 return &_error(
818 "Service failed to register due to failure during registration of relationships"
819 . ( join ",", (@failures) ) . "\n",
820 ""
821 );
822 }
823 return &_success( "Service type $term registered successfully.", $URI );
824 }
825  
826 #Eddie - converted
827 sub _registerServiceTypePayload {
828 my ($payload) = @_;
829 $debug && &_LOG("_registerServiceTypePayload payload=$payload\n");
830 my $Parser = XML::LibXML->new();
831 my $doc = $Parser->parse_string($payload);
832 my $Object = $doc->getDocumentElement();
833 my $obj = $Object->nodeName;
834 return undef unless ( $obj eq 'registerServiceType' );
835 my $type = &_nodeTextContent( $Object, "serviceType" );
836 my $email = &_nodeTextContent( $Object, "contactEmail" );
837 my $auth = &_nodeTextContent( $Object, "authURI" );
838 my $desc = &_nodeCDATAContent( $Object, "Description" );
839 my %relationships;
840 my $x = $doc->getElementsByTagName("Relationship");
841 my $no_relationships = $x->size();
842  
843 for ( my $n = 1 ; $n <= $no_relationships ; ++$n ) {
844 my $relationshipType =
845 $x->get_node($n)->getAttributeNode('relationshipType')
846 ; # may or may not have a name
847 if ($relationshipType) {
848 $relationshipType = $relationshipType->getValue();
849 }
850 else {
851 return
852 "FAILED! must include a relationshipType in every relationship\n";
853 }
854 my @child = $x->get_node($n)->childNodes;
855 foreach (@child) {
856 next unless $_->nodeType == ELEMENT_NODE;
857 my @child2 = $_->childNodes;
858 foreach (@child2) {
859  
860 #print getNodeTypeName($_), "\t", $_->toString,"\n";
861 next unless $_->nodeType == TEXT_NODE;
862 push @{ $relationships{$relationshipType} }, $_->toString;
863 }
864 }
865 }
866 $debug
867 && &_LOG(
868 "got $type, $desc, \%relationships, $email, $auth from registerServiceTypePayload\n"
869 );
870
871 return
872 "FAILED! a service type '$type' was found to have no relationships\n" if keys( %relationships ) == 0 ;
873  
874 return ( $type, $desc, \%relationships, $email, $auth );
875 }
876  
877 =head2 deregisterServiceType
878  
879 =over 3
880  
881 =item * used to deregister a Service term from the Service ontology
882  
883 =item * will fail if any services are instances of that Service Type
884  
885 =item * will fail if any Service Types inherit from that Service Type.
886  
887 =back
888  
889  
890 Input XML :
891  
892 <deregisterServiceType>
893 <serviceType>ServiceOntologyTerm</serviceType>
894 </deregisterServiceType>
895  
896 Ouptut XML :
897  
898 ...Registration Object...
899  
900 =cut
901  
902 sub deregisterServiceType {
903 $CONFIG ||= MOBY::Config->new; # exported by Config.pm
904 my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
905  
906 my ( $pkg, $payload ) = @_;
907 my $OntologyServer = &_getOntologyServer( ontology => 'service' );
908 return &_error( "Message Format Incorrect", "" ) unless ($payload);
909 my ($term) = &_deregisterServiceTypePayload($payload);
910 $debug && &_LOG("deregister serviceType accession $term\n");
911 return &_error(
912 "Must include an accession number to deregister a serviceType", "" )
913 unless ($term);
914 my ( $success, $message, $existingURI ) = $OntologyServer->serviceExists( term => $term ); # hopefully this situation will never happen!
915 return &_error( "Service Type $term does not exist in the ontology", "" )
916 unless ($existingURI);
917
918 my $result = $adaptor->query_service_instance(service_type_uri => $existingURI);
919 my $row = shift(@$result);
920 my $lsid = $row->{lsid};
921
922 return &_error( "A registered service depends on this service type", "" )
923 if ($lsid);
924 my ( $success2, $message2, $deleteURI ) =
925 $OntologyServer->deleteServiceType( term => $term )
926 ; # hopefully this situation will never happen!
927 (($success2 == 0)) && return &_error( $message2, $deleteURI );
928 return &_success( "Service type $term deleted.", $deleteURI );
929 }
930  
931 #Eddie - converted
932 sub _deregisterServiceTypePayload {
933 my ($payload) = @_;
934 my $Parser = XML::LibXML->new();
935 my $doc = $Parser->parse_string($payload);
936 my $Object = $doc->getDocumentElement();
937 my $obj = $Object->nodeName; #Eddie- unsure
938 return undef unless ( $obj eq 'deregisterServiceType' );
939 return &_nodeTextContent( $Object, "serviceType" );
940 }
941  
942 =head2 registerNamespace
943  
944 =over 3
945  
946  
947 =item * used to register a new Namespace in the Namespace controlled vocabulary
948  
949 =item * must provide a valid email address
950  
951 =item * all parameters are required.
952  
953 =back
954  
955  
956 Input XML :
957  
958 <registerNamespace>
959 <namespaceType>NewNamespaceHere</namespaceType>
960 <contactEmail>your_name@contact.address.com</contactEmail>
961 <authURI>Your.URI.here</authURI>
962 <Description>
963 <![CDATA[human readable description]]>
964 </Description>
965 </registerNamespace>
966  
967 Output XML :
968  
969 ...Registration Object...
970  
971  
972 =cut
973  
974 sub registerNamespace {
975  
976 # this contacts the ontology server to register
977 # the ontology and writes the resulting URI into
978 # the MOBY Central database
979 my ( $pkg, $payload ) = @_;
980 my ( $success, $message );
981 my $OntologyServer = &_getOntologyServer( ontology => 'namespace' );
982 $debug
983 && &_LOG(
984 "\n\npayload\n**********************\n$payload\n***********************\n\n"
985 );
986 my ( $term, $auth, $desc, $email ) = &_registerNamespacePayload($payload);
987  
988 $debug && &_LOG("\n\nterm $term\ndesc $desc\nemail $email\nauth $auth");
989 unless ( defined $term && defined $desc && defined $auth && defined $email )
990 {
991 return &_error(
992 "Malformed XML; may be missing required parameters namespaceType, Description, authURI or contactEmail",
993 ""
994 );
995 }
996  
997 # check encoding
998 unless ( decode_utf8( $term ) eq $term && decode_utf8( $desc ) eq $desc && decode_utf8( $auth ) eq $auth && decode_utf8( $email ) eq $email )
999 {
1000 return &_error(
1001 "Invalid character encoding; one or all of namespaceType, Description, authURI or contactEmail were not UTF-8 encoded.",
1002 ""
1003 );
1004 }
1005  
1006 return &_error("Namespace name may not contain spaces or other characters invalid in a URN",
1007 ""
1008 )
1009 if $term =~ /[\/\'\\\s"\&\<\>\[\]\^\`\{\|\}\~%\!\@#\$\*\+=:]/;
1010 return &_error( "Malformed authURI - must not have an http:// prefix", "" )
1011 if $auth =~ '[/:]';
1012 return &_error( "Malformed authURI - must take the form NNN.NNN.NNN", "" )
1013 unless $auth =~ /\./;
1014 return &_error(
1015 "Malformed email - must be a valid email address of the form name\@organization.foo",
1016 ""
1017 )
1018 unless $email =~ /\S\@\S+\.\S+/;
1019 my ( $exists, $exists_message, $URI ) =
1020 $OntologyServer->namespaceExists( term => $term )
1021 ; # success = 1 if it does
1022 ( ( $exists == 1 )
1023 && return &_error( "Namespace $term already exists", $URI ) );
1024 ( $success, $message, $URI ) = $OntologyServer->createNamespace(
1025 node => $term,
1026 description => $desc,
1027 authority => $auth,
1028 contact_email => $email
1029 );
1030 ($success == 0) && return &_error( $message, $URI );
1031 return &_success( "Namespace type $term registered successfully.", $URI );
1032 }
1033  
1034 #Eddie - converted
1035 sub _registerNamespacePayload {
1036 my ($payload) = @_;
1037 my $Parser = XML::LibXML->new();
1038 my $doc = $Parser->parse_string($payload);
1039 my $Object = $doc->getDocumentElement();
1040 my $obj = $Object->nodeName;
1041 return undef unless ( $obj eq 'registerNamespace' );
1042 my $type = &_nodeTextContent( $Object, "namespaceType" );
1043 my $authURI = &_nodeTextContent( $Object, "authURI" );
1044 my $desc = &_nodeCDATAContent( $Object, "Description" );
1045 my $contact = &_nodeTextContent( $Object, "contactEmail" );
1046 return ( $type, $authURI, $desc, $contact );
1047 }
1048  
1049 =head2 deregisterNamespace
1050  
1051 =over
1052  
1053 =item * used to remove a Namespace from the controlled vocabulary
1054  
1055 =item * will fail if that namespace is being used by any services
1056  
1057 =item * you will recieve an email for confirmation of the deregistration
1058  
1059 =back
1060  
1061  
1062 Input XML :
1063  
1064 <deregisterNamespace>
1065 <namespaceType>MyNamespace</namespaceType>
1066 </deregisterNamespace>
1067  
1068 Ouptut XML :
1069  
1070 ...Registration Object...
1071  
1072  
1073 =cut
1074  
1075 sub deregisterNamespace {
1076 $CONFIG ||= MOBY::Config->new; # exported by Config.pm
1077 my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
1078  
1079 my ( $pkg, $payload ) = @_;
1080 my $OntologyServer = &_getOntologyServer( ontology => 'namespace' );
1081 return &_error( "Message Format Incorrect", "" ) unless ($payload);
1082 my ($term) = &_deregisterNamespacePayload($payload);
1083 $debug && &_LOG("deregister namespaceType accession $term\n");
1084 return &_error( "Must include a Namespace type to deregister.", "" )
1085 unless ($term);
1086 my ( $success, $message, $existingURI ) =
1087 $OntologyServer->namespaceExists( term => $term );
1088 return &_error( "Namespace Type $term does not exist", "" )
1089 unless ($existingURI);
1090 my ($err, $errstr) = $adaptor->check_namespace_usage(namespace_type_uris => $existingURI,
1091 type => $term);
1092 return &_error( $errstr, "")
1093 if ($err);
1094
1095 my ( $success2, $message2, $URI ) =
1096 $OntologyServer->deleteNamespace( term => $term );
1097 ($success2 == 0) && return &_error( $message2, $URI );
1098 return &_success( "Namespace type $term deregistered successfully.", $URI );
1099 }
1100  
1101 #Eddie - converted
1102 sub _deregisterNamespacePayload {
1103 my ($payload) = @_;
1104 my $Parser = XML::LibXML->new();
1105 my $doc = $Parser->parse_string($payload);
1106 my $Object = $doc->getDocumentElement();
1107 my $obj = $Object->nodeName;
1108 return undef unless ( $obj eq 'deregisterNamespace' );
1109 return &_nodeTextContent( $Object, "namespaceType" );
1110 }
1111  
1112 =head2 registerService
1113  
1114 =over 3
1115  
1116 =item * all elements are required
1117  
1118 =item * a service must have at least one Input OR Output Object Class. Either Input or Output may be blank to represent "PUT" or "GET" services respectively
1119  
1120 =item * the contactEmail address must be valid, as it is used to authorize deregistrations and changes to the service you registered.
1121  
1122 =item * the "authoritativeService" tag is used to indicate whether or not the registered service is "authoritative" for that transformation. i.e. if anyone else were to perform the same transformation they would have to have obtained the information to do so from you. This is similar to, but not necessarily identical to, mirroring someone elses data, since the data in question may not exist prior to service invocation.
1123  
1124 =item * only Input Secondary articles are defined during registration; Output Secondary objects are entirely optional and may or may not be interpreted Client-side using their articleName tags.
1125  
1126 =item * Service Categories:
1127  
1128 =over 3
1129  
1130 =item * moby - for services that use the MOBY SOAP messaging format and object structure (i.e. the objects used in service transaction inherit from the root 'Object' Class in the MOBY Class ontology).
1131  
1132 =over 2
1133  
1134 =item * authURI - a URI representing your organization (e.g. yourdomain.com); no http-prefix, and no trailing path information is allowed.
1135  
1136 =item * serviceName - an arbitrary, but unique, name for your service within your authURI namespace
1137  
1138 =item * URL - the URL to a SOAP CGI server that can invoke a method as described by your serviceName
1139  
1140 =back
1141  
1142 =item * wsdl - for other SOAP services that do not use the MOBY messaging format. The other elements in the registration should be interpreted as follows:
1143  
1144 =over 2
1145  
1146 =item * authURI - a URI representing your organization (e.g. yourdomain.com); no http-prefix, and no trailing path information is allowed.
1147  
1148 =item * serviceName - an arbitrary, but unique, name for your service within your authURI namespace
1149  
1150 =item * URL - the URL from which a WSDL document describing your service can be retrieved by an HTTP GET call.
1151  
1152 =back
1153  
1154 =item * Comments about Input and Output for MOBY and non-MOBY services
1155  
1156 =over 2
1157  
1158 =item * in "moby" services, the input and output messaging structure is defined by the BioMOBY API, and the services use data Objects that are defined in the Class ontology as inheriting from the root "Object" Class.
1159  
1160 =item * For "wsdl" services, there is additional flexibility:
1161  
1162 =over 2
1163  
1164 =item * Similar to a "moby" service, your "wsdl" service must consume/produce named data types. These are represented as LSID's
1165  
1166 =item * YOU DO NOT NEED TO REGISTER THESE DATA TYPES in MOBY Central; it is up to you what your LSID's represent, and MOBY Central WILL NOT try to resolve them!
1167  
1168 =item * You may mix ontologies when describing your service - i.e. you may freely use any MOBY Object as your input or (XOR) your output and use a non-MOBY object (LSID) for the alternate so long as you follow the MOBY message structure for the parameter that uses the MOBY Object
1169  
1170 =over 2
1171  
1172 =item * You may register, for example, a service that consumes a non-MOBY data Class and outputs a MOBY data class, so long as you follow the MOBY Messaging format for the output data
1173  
1174 =item * You may register, for example, a service that consumes a MOBY data Class and outputs a non-MOBY data class, so long as you follow the MOBY Messaging format for the input data
1175  
1176 =item * NOTE: Nether of the cases above are considered MOBY services, and are therefore described in the category of "soap" service
1177  
1178 =back
1179  
1180 =back
1181  
1182 =item * secondaryArticles - not applicable; should be left out of message.
1183  
1184 =back
1185  
1186 =back
1187  
1188 =back
1189  
1190  
1191 Input XML :
1192  
1193 <registerService>
1194 <Category>moby</Category> <!-- one of 'moby', 'moby-async', 'doc-literal', 'doc-literal-async', 'cgi', 'cgi-async'; 'moby' and 'moby-async' are RPC encoded -->
1195 <serviceName>YourServiceNameHere</serviceName>
1196 <serviceType>TypeOntologyTerm</serviceType>
1197 <signatureURL>http://path.to/your/signature/RDF.rdf</sisgnatureURL>
1198 <servieLSID>urn:lsid:biomoby.org:serviceinstance:myservice:version</serviceLSID>
1199 <authURI>your.URI.here</authURI>
1200 <URL>http://URL.to.your/Service.script</URL>;
1201 <contactEmail>your_name@contact.address.com</contactEmail>
1202 <authoritativeService>1 | 0 </authoritativeService>
1203 <Description><![CDATA[
1204 human readable COMPREHENSIVE description of your service]]>
1205 </Description>
1206 <Input>
1207 <!-- zero or more Primary (Simple and/or Collection) articles -->
1208 </Input>
1209 <secondaryArticles>
1210 <!-- zero or more INPUT Secondary articles -->
1211 </secondaryArticles>
1212 <Output>
1213 <!-- zero or more Primary (Simple and/or Collection) articles -->
1214 </Output>
1215 </registerService>
1216  
1217 Output XML :
1218  
1219 ...Registration Object...
1220  
1221 There are two forms of Primary articles:
1222  
1223 =over 3
1224  
1225 =item * Simple - the article consists of a single MOBY Object
1226  
1227 =item * Collection - the article consists of a collection ("bag") of MOBY Objects (not necessarily the same object type).
1228  
1229 =over 3
1230  
1231 =item * Their number/order is not relevant, nor predictable
1232  
1233 =item * If order is important to the service provider, then a collection should not be used, rather the collection should be broken into named Simple parameters. This may impose limitations on the the types of services that can be registered in MOBY Central. If it becomes a serious problem, a new Primary article type will be added in a future revision.
1234  
1235 =item * The use of more than one Class in a collection is difficult to interpret, though it is equally difficult to envision a service that would require this. It is purposely left losely defined since any given Service Instance can tighten up this definition during the registration process.
1236  
1237 =item * A collection may contain zero or more Objects of each of the Classes defined in the XML during Service Instance registration.
1238  
1239 =over 3
1240  
1241 =item * Each distinct Object Class only needs to be included once in the XML. Additional entries of that Class within the same Collection definition must be ignored.
1242  
1243 =back
1244  
1245 =back
1246  
1247 =back
1248  
1249 An example of the use of each of these might be another BLAST service, where you provide the sequences that make up the Blast database as well as the sequence to Blast against it. The sequences used to construct the database might be passed as a Collection input article containing multiple Sequence Objects, while the sequence to Blast against it would be a Simple input article consisting of a single Sequence Object.
1250  
1251 There is currently only one form of Secondary article:
1252  
1253 =over 3
1254  
1255 =item * Secondary - the article may or may not be specifically configured by the client as Input, and may or may not be returned by the Service as output.
1256  
1257 =over 3
1258  
1259 =item * In the case of inputs, they are generally user-configurable immediately prior to service invocation.
1260  
1261 =item * During service invocation a Client must send all Secondary articles defined in the Service Instance, even if no value has been provided either as default, or Client-side.
1262  
1263 =item * Secondary articles that are considered "required" by the Service should be registered with a default value.
1264  
1265 =item * The Service may fail if an unacceptable value is passed for any Secondary Article.
1266  
1267 =back
1268  
1269 =back
1270  
1271  
1272 Articles are, optionally, named using the articleName attribute. This might be used if, for example, the service requires named inputs. The order of non-named articles in a single Input or Output set MUST not be meaningful.
1273  
1274 The XML structure of these articles is as follows:
1275  
1276 =over 3
1277  
1278 =item * Simple (note that the lsid attribute of the objectType and Namespace element need only be present in the article when it is present in a response document from MOBY Central such as the result of a findService call. These attributes are ignored by MOBY Central when they appear in input messages such as registerService)
1279  
1280 <Simple articleName="NameOfArticle">
1281 <objectType lsid='urn:lsid:...'>ObjectOntologyTerm</objectType>
1282 <Namespace lsid='urn:lsid:...'>NamespaceTerm</Namespace>
1283 <Namespace lsid='urn:lsid:...'>...</Namespace><!-- one or more... -->
1284 </Simple>
1285  
1286 =item * Collection note that articleName of the contained Simple objects is not required, and is ignored.
1287  
1288  
1289 <Collection articleName="NameOfArticle">
1290 <Simple>......</Simple> <!-- Simple parameter type structure -->
1291 <Simple>......</Simple> <!-- DIFFERENT Simple parameter type (used only when multiple Object Classes appear in a collection) -->
1292 </Collection>
1293  
1294 =item * Secondary
1295  
1296  
1297 <Parameter articleName="NameOfArticle">
1298 <datatype>Integer|Float|String|DateTime</datatype>
1299 <description><![CDATA[freetext description of purpose]]></description>
1300 <default>...</default> <!-- any/all of these -->
1301 <max>...</max> <!-- ... -->
1302 <min>...</min> <!-- ... -->
1303 <enum>...<enum> <!-- ... -->
1304 <enum>...<enum> <!-- ... -->
1305 </Parameter>
1306  
1307 =back
1308  
1309  
1310 =cut
1311  
1312 # inputXML (FOR CGI GET SERVICES):
1313 # <registerService>
1314 # <Category>cgi</Category>
1315 # <serviceName>YourServiceNameHere</serviceName>
1316 # <serviceType>YourServiceTypeHere</serviceType>
1317 # <authURI>your.URI.here</authURI>
1318 # <contactEmail>blah@blow.com</contactEmail>
1319 # <URL>http://URL.to.your/CGI.pl</URL>
1320 # <authoritativeService>your.URI.here</authoritativeService>
1321 # <Input>
1322 # <!-- zero or more pimary (simple or collection) articles -->
1323 # </Input>
1324 # <Output>
1325 # <!-- zero or more pimary (simple or collection) articles -->
1326 # </Output>
1327 # <secondaryArticles>
1328 # </secondaryArticles>
1329 # <Description><![CDATA[
1330 # human readable description of your service]]>
1331 # </Description>
1332 # </registerService>
1333  
1334 sub registerService {
1335 my ( $pkg, $payload ) = @_;
1336 my (
1337 $serviceName, $serviceType, $AuthURI,
1338 $contactEmail, $URL, $authoritativeService,
1339 $desc, $Category, $INPUTS,
1340 $OUTPUTS, $SECONDARY, $signatureURL, $serviceLSID
1341 )
1342 = &_registerServicePayload($payload);
1343  
1344 #--------RDFagent call----------------------------------------
1345
1346 # THIS IS A CALL TO moby cENTRAL REGISTER SERVICE THAT CONTAINED ONLY A sIGNATUREURL
1347 # THE IMPLICATION IS THAT THEY ARE ASKING YOU TO VISIT THEIR urL now!!!!
1348 if ( defined $signatureURL ) {
1349 my $ch = 0;
1350 my $i; # first check if any other parameters were filled-in. If so, then the implication is that they want us to register based on the data they have provided
1351 foreach $i ( $serviceName, $serviceType, $AuthURI, $contactEmail, $URL, $desc)
1352 {
1353 if ( defined $i && $i ne "") {
1354 $ch = 1;
1355 }
1356 }
1357  
1358 if ( $ch == 0 ) {
1359 my $conf = MOBY::Config->new();
1360 my $path = $conf->{mobycentral}->{rdfagent};
1361 #Assumes JAVA_HOME is set!!!
1362 my $JAVA_HOME = $ENV{JAVA_HOME} || "";
1363 if ($JAVA_HOME) {
1364 $JAVA_HOME .="/bin/java";
1365 } else {
1366 $JAVA_HOME ="java";
1367 }
1368 $signatureURL =~ s/\s+//g;
1369 my $exit = system ("$JAVA_HOME", "-DRDFagent.home=$path", '-jar', $path. '/RDFagent.jar','-url',$signatureURL);
1370 my $rez = _how_exit($exit);
1371 return &_success( "The RDFagent call was successful.",
1372 "",""
1373 )
1374 if ( $rez == 0 );
1375 return &_error(
1376 "The call to the RDF agent resulted in failure. The agent encountered problems communicating with the registry. Please try again.", "" )
1377 if ( $rez == 10 );
1378 return &_error(
1379 "The call to agent failed because the agent is using a bad URL/URI for the registry. Please contact the registry's administrator and let them know.", "" )
1380 if ( $rez == 11 );
1381 return &_error(
1382 "The RDF agent call was partially successful, but there was an internal error. Please let the administrator of the registry know about this problem.", "" )
1383 if ( $rez == 12 );
1384 return &_error(
1385 "No services in the registry match the given URL and the signatureURL didn't contain any services. The RDF agent was called, but found nothing useful.", "" )
1386 if ( $rez == 13 );
1387 return &_success( "The RDFagent call was successful. All services described by $signatureURL have been removed because the URL was unreachable.",
1388 "",""
1389 )
1390 if ( $rez == 14 );
1391
1392 return &_error(
1393 "The call to the RDF agent resulted in failure and I am not sure why. Please try again and if the error persists, let the administrator of the registry know.", "" )
1394 if ( $rez != 0 );
1395  
1396 }
1397 }
1398  
1399 #---------------------------------------------------------------
1400  
1401 $authoritativeService = (defined($authoritativeService) && $authoritativeService) ? 1 : 0;
1402 my $error;
1403 $error .= "missing serviceName \n" unless defined $serviceName;
1404 $error .= "missing serviceType \n" unless defined $serviceType;
1405 $error .= "invalid character string for serviceName. Must start with a letter followed by [A-Za-z0-9_]\n" if ($serviceName =~ /^[^A-Za-z]/);
1406 $error .= "invalid character string for serviceName. Must start with a letter followed by [A-Za-z0-9_]\n" if ($serviceName =~ /^.+?[^A-Za-z0-9_]/);
1407 $error .= "service name may not contain spaces or other characters invalid in a URN" if $serviceName =~ /[\/\'\\\s"\&\<\>\[\]\^\`\{\|\}\~%\!\@#\$\*\+=]/;
1408  
1409 # $error .="missing signatureURL \n" unless defined $signatureURL;
1410 $error .= "missing authURI \n" unless defined $AuthURI;
1411 $error .= "invalid character encoding; authURI not encoded as UTF-8\n" unless decode_utf8( $AuthURI ) eq $AuthURI;
1412 $error .= "missing contactEmail \n" unless defined $contactEmail;
1413 $error .= "invalid character encoding; contactEmail not encoded as UTF-8\n" unless decode_utf8( $contactEmail ) eq $contactEmail;
1414 return &_error( "Malformed authURI - must not have an http:// prefix", "" )
1415 if $AuthURI =~ '[/:]';
1416 return &_error( "Malformed authURI - must take the form NNN.NNN.NNN", "" )
1417 unless $AuthURI =~ /\./;
1418 return &_error("Malformed email - must be a valid email address of the form name\@organization.foo","")
1419 unless $contactEmail =~ /\S\@\S+\.\S+/;
1420 $error .= "missing URL \n" unless defined $URL;
1421 $error .= "invalid character encoding; URL not encoded as UTF-8\n" unless decode_utf8( $URL ) eq $URL;
1422 $error .= "missing description \n" unless defined $desc;
1423 $error .= "invalid character encoding; description not encoded as UTF-8\n" unless decode_utf8( $desc ) eq $desc;
1424 $error .= "missing Category \n" unless defined $Category;
1425 $error .= "invalid character encoding; service name not encoded as UTF-8\n" unless decode_utf8( $serviceName ) eq $serviceName;
1426 return &_error( "malformed payload $error\n\n", "" ) if ($error);
1427 return &_error(
1428 "Category may take the (case sensitive) values 'moby', 'moby-async', 'cgi', 'cgi-async', 'doc-literal', and 'doc-literal-async', \n",
1429 ""
1430 )
1431 unless (
1432 ( $Category eq "wsdl" )
1433 || ( $Category eq "moby" )
1434 || ( $Category eq "moby-async" )
1435 || ( $Category eq "cgi" )
1436 || ( $Category eq "cgi-async" )
1437 || ( $Category eq "doc-literal" )
1438 || ( $Category eq "doc-literal-async"));
1439  
1440 #test the existence of the service
1441 return &_error( "This service already exists", "" ) if (MOBY::service_instance->new(
1442 servicename => $serviceName,
1443 authority_uri => $AuthURI,
1444 test => 1));
1445  
1446  
1447 my @IN = @{$INPUTS};
1448 my @OUT = @{$OUTPUTS};
1449 my @SECS = @{$SECONDARY};
1450 return &_error(
1451 "must include at least one input and/or one output object type", "" )
1452 unless ( scalar @IN || scalar @OUT );
1453 my %objects_to_be_validated;
1454 foreach ( @IN, @OUT ) {
1455  
1456 foreach my $objectName ( &_extractObjectTypes($_) ) {
1457 $objects_to_be_validated{$objectName} = 1;
1458 }
1459 }
1460 my $OS = MOBY::OntologyServer->new( ontology => 'object' );
1461 foreach ( keys %objects_to_be_validated ) {
1462 my ( $valid, $message, $URI ) = $OS->objectExists( term => $_ );
1463 return &_error( "$message", "$URI" )
1464 unless ( $valid
1465 || ( ( $_ =~ /urn:lsid/i ) && !( $_ =~ /urn:lsid:biomoby.org/i ) )
1466 ); # either valid, or a non-moby LSID
1467 }
1468 $debug
1469 && &_LOG(
1470 "\n\n\aall objects okay - either valid MOBY objects, or LSID's\n");
1471 $OS = MOBY::OntologyServer->new( ontology => 'service' );
1472 my ( $valid, $message, $URI ) = $OS->serviceExists( term => $serviceType );
1473  
1474 #print STDERR "\n\nChecking $URI\n\n";
1475 return &_error( "$message", "$URI" )
1476 unless (
1477 $valid
1478 || ( ( $serviceType =~ /urn:lsid/i )
1479 && !( $serviceType =~ /urn:lsid:biomoby.org/i ) )
1480 ); # either valid, or a non-MOBY LSID
1481 #print STDERR "\n\nChecking $URI OK!!\n\n";
1482 # right, registration should be successful now!
1483 my $SVC = MOBY::service_instance->new(
1484 category => $Category,
1485 servicename => $serviceName,
1486 service_type => $serviceType,
1487 authority_uri => $AuthURI,
1488 url => $URL,
1489 contact_email => $contactEmail,
1490 authoritative => $authoritativeService,
1491 description => $desc,
1492 signatureURL => $signatureURL,
1493 lsid => $serviceLSID
1494 );
1495 return &_error( "Service registration failed for unknown reasons", "" ) if ( !defined $SVC );
1496  
1497 $debug && &_LOG("new service instance created\n");
1498  
1499 foreach my $IN (@IN) {
1500 my ( $success, $msg ) = &_registerArticles( $SVC, "input", $IN, undef );
1501 unless ( $success == 1 ){
1502 $SVC->DELETE_THYSELF;
1503 return &_error("Registration Failed During INPUT Article Registration: $msg", "" )
1504 }
1505 }
1506 foreach my $OUT (@OUT) {
1507 my ( $success, $msg ) = &_registerArticles( $SVC, "output", $OUT, undef );
1508 unless ( $success == 1 ){
1509 $SVC->DELETE_THYSELF;
1510 return &_error("Registration Failed During OUTPUT Article Registration: $msg", "" )
1511 }
1512 }
1513 foreach my $SEC (@SECS) {
1514 my ( $success, $msg ) = &_registerArticles( $SVC, "secondary", $SEC, undef );
1515 unless ( $success == 1 ){
1516 $SVC->DELETE_THYSELF;
1517 return &_error("Registration Failed During SECONDARY Article Registration: $msg", "" )
1518 }
1519 }
1520  
1521 # we're going to do a findService here to find the service that we just created
1522 # and use the resulting XML to create a MOBY::Client::ServiceInstance object
1523 # that we can then use to retrieve the RDF for that service signature.
1524 # this is roundabout, I agree, but it is the most re-usable way to go at
1525 # the moment.
1526 my ( $si, $reg ) = &findService(
1527 '', "<findService>
1528 <authURI>$AuthURI</authURI>;
1529 <serviceName>$serviceName</serviceName>;
1530 </findService>"
1531 );
1532 unless ($si) {
1533 $SVC->DELETE_THYSELF;
1534 return &_error("Registration Failed - newly registered service could not be discovered","");
1535 }
1536  
1537  
1538 my $RDF = _getServiceInstanceRDF(name=>$serviceName, auth=>$AuthURI);
1539 unless ($RDF) {
1540 return &_success( "Registration successful but unable to create RDF - please contact your MOBY Central administrator",
1541 $SVC->lsid, "" );
1542 }
1543 unless ( $RDF =~ /RDF/ ) {
1544 return &_success(
1545 "Registration successful but RDF is not correctly formatted:\n\n $RDF",
1546 $SVC->lsid, "" );
1547 }
1548 # wrap RDF in CDATA - moved it here, so that we can return the 'bad' rdf above
1549 return &_success( "Registration successful", $SVC->lsid,
1550 "<![CDATA[$RDF]]>" );
1551 }
1552  
1553 sub _getServiceInstanceRDF {
1554 my ( %args ) = @_;
1555 my $x = MOBY::RDF::Ontologies::Services->new;
1556 my $xml = "";
1557 eval {
1558 $xml = $x->findService(
1559 {
1560 serviceName => $args{name},
1561 authURI => $args{auth},
1562 isAlive => 'no'
1563 }
1564 );
1565 };
1566 if ($@) {
1567 return "";
1568 }
1569 print STDERR "$xml\n";
1570 if ($x) {
1571 return "$xml" unless ( $xml =~ /title>Service Instance Not Found</ );
1572 }
1573 return "";
1574 }
1575  
1576 #Eddie - Converted
1577 sub _registerArticles {
1578 my ( $SVC, $inout, $node, $collid ) = @_
1579 ; # node is a node of the XML dom representing an article to be registered
1580 return ( -1, 'Bad node' ) unless $node->nodeType == ELEMENT_NODE;
1581  
1582 # this is a Simple, Collection, or Parameter object
1583 my $simp_coll = $node->nodeName;
1584 $debug && &_LOG("TAGNAME in $inout _registerArticle is $simp_coll");
1585 my $article = $node->getAttributeNode("articleName");
1586  
1587 if ($article) {
1588 $article = $article->getValue();
1589 }
1590 return (-1,"Invalid articlename name found. Articlenames may not contain spaces or other special characters.")
1591 if $article =~ /([\+\=:\s\&\<\>\[\]\^\`\{\|\}\~\(\)\\\/\$\#\@\,\|\?\.!\*\;\'\"])/;
1592
1593 #check encoding for those articles that are not the empty string or a string of whitespace
1594 return (-1,"Invalid character encoding; articlename not UTF-8 encoded.")
1595 unless decode_utf8( $article ) eq $article;
1596  
1597 $debug && &_LOG("ARTICLENAME in _registerArticle is $article");
1598 if (lc($inout) eq "input"){
1599 return (-1, "Input Simples and collections are required to have an articleName as of API version 0.86") if (!$article && !$collid);
1600 }
1601  
1602 my ( $object_type, @namespaces );
1603 if ( $simp_coll eq "Collection" ) {
1604 $debug && &_LOG("Collection!\n");
1605 my $collection_id;
1606 if ( $inout eq 'input' ) {
1607 $collection_id =
1608 $SVC->add_collection_input( article_name => $article );
1609 }
1610 elsif ( $inout eq 'output' ) {
1611 $collection_id =
1612 $SVC->add_collection_output( article_name => $article );
1613 }
1614 else {
1615 $SVC->DELETE_THYSELF;
1616 return ( -1, "found article that was neither input nor output" );
1617 }
1618  
1619 my $Simples = $node->getElementsByTagName('Simple');
1620 my $length = $Simples->size();
1621 unless ( $length > 0 ) {
1622 return ( -1,"Your collection must be a collection of one Simple type"
1623 );
1624 }
1625 unless ( $length == 1 ) {
1626 return ( -1,"As of API v0.86, Collections must not be of more than one Simple type"
1627 );
1628 }
1629 for ( my $x = 1 ; $x <= $length ; ++$x ) {
1630 my ( $success, $message ) = &_registerArticles( $SVC, $inout, $Simples->get_node($x), $collection_id );
1631 unless ( $success == 1 ) { return ( -1, $message ); }
1632 }
1633 } elsif ( $simp_coll eq "Simple" ) {
1634 my $article = $node->getAttributeNode("articleName");
1635 $article = $article->getValue() if $article;
1636  
1637 # get object type and its URI from the ontoogy server
1638 my $types = $node->getElementsByTagName('objectType');
1639 my $OE = MOBY::OntologyServer->new( ontology => "object" );
1640 foreach ( $types->get_node(1)->childNodes ) { # should only ever be one!
1641 ( $_->nodeType == TEXT_NODE ) && ( $object_type = $_->toString );
1642 }
1643 my ( $success, $message, $typeURI ) =
1644 $OE->objectExists( term => $object_type );
1645 if ( ( !($success) && ( $object_type =~ /urn:lsid:biomoby.org/i ) )
1646 || ( !($success) && !( $object_type =~ /urn:lsid/i ) ) )
1647 { # if the object doesn't exist, and it isn't an LSID
1648 $SVC->DELETE_THYSELF;
1649 return ( -1,
1650 "object: $object_type does not exist, and is not an LSID" );
1651 } # kill it all unless this was successful!
1652 my $namespace_string;
1653 my $namespaces = $node->getElementsByTagName('Namespace');
1654 my $num_ns = $namespaces->size();
1655 $OE = MOBY::OntologyServer->new( ontology => "namespace" );
1656 for ( my $n = 1 ; $n <= $num_ns ; ++$n ) {
1657 foreach my $name ( $namespaces->get_node($n)->childNodes ) {
1658 if ( $name->nodeType == TEXT_NODE ) {
1659 my $term = $name->toString;
1660 my ( $success, $message, $URI ) =
1661 $OE->namespaceExists( term => $term );
1662 if ( ( !($success) && ( $term =~ /urn:lsid:biomoby.org/i ) )
1663 || ( !($success) && !( $term =~ /urn:lsid/i ) ) )
1664 { # if the object doesn't exist, and it isn't an LSID
1665 $SVC->DELETE_THYSELF;
1666 return ( -1,
1667 "namespace: $term doesn't exist and is not an LSID"
1668 );
1669 }
1670 $namespace_string .= $URI . ",";
1671 }
1672 }
1673 }
1674 chop($namespace_string); # remove trailing comma
1675  
1676 my $service_instance_id;
1677 unless ($collid)
1678 { # this SIMPLE is either alone, or is part of a COLLECTION ($collid > 0)
1679 # therefore we want either its service instance ID, or its Collection ID.
1680 $service_instance_id = $SVC->service_instance_id;
1681 } # one or the other, but not both
1682 if ( $inout eq 'input' ) {
1683 my $sinput = $SVC->add_simple_input(
1684 object_type_uri => $typeURI,
1685 namespace_type_uris => $namespace_string,
1686 article_name => $article,
1687 collection_input_id => $collid,
1688 );
1689 unless ($sinput) {
1690 $SVC->DELETE_THYSELF;
1691 return ( -1, "registration failed during registration of input object $typeURI. Unknown reasons.");
1692 }
1693 }
1694 elsif ( $inout eq 'output' ) {
1695 my $soutput = $SVC->add_simple_output(
1696 object_type_uri => $typeURI,
1697 namespace_type_uris => $namespace_string,
1698 article_name => $article,
1699 collection_output_id => $collid,
1700 );
1701 unless ($soutput) {
1702 $SVC->DELETE_THYSELF;
1703 return ( -1,"registration failed during registration of output object $typeURI. Unknown reasons."
1704 );
1705 }
1706 }
1707 }
1708 elsif ( $simp_coll eq "Parameter" ) {
1709 my $parameter = $node;
1710 my $article = $parameter->getAttributeNode("articleName");
1711 $article = $article->getValue() if $article;
1712
1713 return (-1,"Secondary inputs must be registered with articlenames.")
1714 unless $article;
1715
1716 # make sure that the articlename is corrects
1717 return (-1,"Secondary input had an invalid articlename. Articlenames may not contain spaces or other special characters.")
1718 if $article =~ /([\+\=\':\s\"\&\<\>\[\]\^\`\{\|\}\~\(\)\\\/\$\#\@\,\|\?\.!\*\;])/;
1719
1720 my ( $datatype, $def, $max, $min, $description, @enums );
1721 my $types = $parameter->getElementsByTagName('datatype');
1722 if ( $types->get_node(1) ) {
1723 foreach ( $types->get_node(1)->childNodes )
1724 { # should only ever be one!
1725 ( $_->nodeType == TEXT_NODE ) && ( $datatype .= $_->nodeValue );
1726 }
1727 }
1728  
1729 #ensure that thet type is correct (Integer | String | Float | DateTime| Boolean)
1730 $datatype =~ s/\s//g;
1731 my $secondaries = $CONFIG->{valid_secondary_datatypes};
1732 my $valid;
1733 map { $valid = 1 if $datatype eq $_ } @{$secondaries};
1734 unless ($valid) {
1735 $SVC->DELETE_THYSELF;
1736 return ( -1,"Registration failed. $datatype must be one of type Integer, String, DateTime, Boolean or Float."
1737 );
1738 }
1739
1740 my $defs = $parameter->getElementsByTagName('default');
1741 if ( $defs->get_node(1) ) {
1742 foreach ( $defs->get_node(1)->childNodes )
1743 { # should only ever be one!
1744 ( $_->nodeType == TEXT_NODE ) && ( $def .= $_->nodeValue );
1745 }
1746 }
1747 my $maxs = $parameter->getElementsByTagName('max');
1748 if ( $maxs->get_node(1) ) {
1749 foreach ( $maxs->get_node(1)->childNodes )
1750 { # should only ever be one!
1751 ( $_->nodeType == TEXT_NODE ) && ( $max .= $_->nodeValue );
1752 }
1753 }
1754 my $mins = $parameter->getElementsByTagName('min');
1755 if ( $mins->get_node(1) ) {
1756 foreach ( $mins->get_node(1)->childNodes )
1757 { # should only ever be one!
1758 ( $_->nodeType == TEXT_NODE ) && ( $min .= $_->nodeValue );
1759 }
1760 }
1761 my $descs = $parameter->getElementsByTagName('description');
1762 if ( $descs->get_node(1) ) {
1763 foreach ( $descs->get_node(1)->childNodes )
1764 { # should only ever be one!
1765 ( $_->nodeType == TEXT_NODE ) && ( $description .= $_->nodeValue );
1766 }
1767 }
1768  
1769 my $enums = $parameter->getElementsByTagName('enum');
1770 my $numenums = $enums->size();
1771 for ( my $n = 1 ; $n <= $numenums ; ++$n ) {
1772 foreach ( $enums->get_node($n)->childNodes )
1773 { # should only ever be one!
1774 ( $_->nodeType == TEXT_NODE )
1775 && ( push @enums, $_->nodeValue );
1776 }
1777 }
1778 my $enum_string = join "", ( map { $_ . "," } @enums );
1779 chop $enum_string; # get rid of trailing comma
1780 $datatype =~ s/^\s+//;
1781 $datatype =~ s/\s+$//;
1782 $def =~ s/^\s+//;
1783 $def =~ s/\s+$//;
1784 $max =~ s/^\s+//;
1785 $max =~ s/\s+$//;
1786 $min =~ s/^\s+//;
1787 $min =~ s/\s+$//;
1788 my $sec = $SVC->add_secondary_input(
1789 default_value => $def,
1790 maximum_value => $max,
1791 minimum_value => $min,
1792 enum_value => $enum_string,
1793 datatype => $datatype,
1794 article_name => $article,
1795 description => $description,
1796 );
1797  
1798 unless ($sec) {
1799 $SVC->DELETE_THYSELF;
1800 return ( -1,
1801 "registration failed during registration of parameter $article. Must be of type Integer, String, DateTime, or Float."
1802 );
1803 }
1804 }
1805 return 1;
1806 }
1807  
1808 #Eddie - converted
1809 sub _registerServicePayload {
1810 my ($payload) = @_;
1811 my $Parser = XML::LibXML->new();
1812 my $doc = $Parser->parse_string($payload);
1813 my $Object = $doc->getDocumentElement();
1814 my $obj = $Object->nodeName;
1815 return undef unless ( $obj eq 'registerService' );
1816 my $serviceName = &_nodeTextContent( $Object, "serviceName" );
1817 my $Category = &_nodeTextContent( $Object, "Category" );
1818 my $serviceType = &_nodeTextContent( $Object, "serviceType" );
1819 my $AuthURI = &_nodeTextContent( $Object, "authURI" );
1820 my $contactEmail = &_nodeTextContent( $Object, "contactEmail" );
1821 my $authoritativeService =
1822 &_nodeTextContent( $Object, "authoritativeService" );
1823 my $URL = &_nodeTextContent( $Object, "URL" );
1824 my $signatureURL = &_nodeTextContent( $Object, "signatureURL" );
1825 my $serviceLSID = &_nodeTextContent( $Object, "serviceLSID" );
1826 my $desc = &_nodeCDATAContent( $Object, "Description" );
1827 my $INPUTS = &_nodeRawContent( $Object, "Input" ); # returns array ref
1828 my $OUTPUTS = &_nodeRawContent( $Object, "Output" ); # returns array ref
1829 my $SECONDARIES =
1830 &_nodeRawContent( $Object, "secondaryArticles" ); # returns array ref
1831 return (
1832 $serviceName, $serviceType, $AuthURI,
1833 $contactEmail, $URL, $authoritativeService,
1834 $desc, $Category, $INPUTS,
1835 $OUTPUTS, $SECONDARIES, $signatureURL, $serviceLSID
1836 );
1837 }
1838  
1839 #Eddie - converted
1840 sub _extractObjectTypes {
1841 my ($DOM) = @_; # DOM is either a <Simple/> or a <Collection/> article
1842 $debug && &_LOG("\n\n\nExtracting object types from \n$DOM \n\n");
1843 unless ( ref($DOM) =~ /^XML/ ) {
1844 my $Parser = XML::LibXML->new();
1845 my $doc = $Parser->parse_string($DOM);
1846 $DOM = $doc->getDocumentElement();
1847 }
1848 my $x = $DOM->getElementsByTagName("objectType");
1849 my @objectnames;
1850 my $l = $x->size(); # might be a Collection object with multiple simples...
1851 for ( my $n = 1 ; $n <= $l ; ++$n ) {
1852 my @child = $x->get_node($n)->childNodes;
1853 foreach (@child) {
1854 $debug
1855 && &_LOG( getNodeTypeName($_), "\t", $_->toString, "\n" )
1856 ; #hopefully uses MobyXMLConstants.pm
1857 next unless ( $_->nodeType == TEXT_NODE );
1858 my $name = $_->toString;
1859 chomp $name;
1860 push @objectnames, $name;
1861 }
1862 }
1863 return (@objectnames);
1864 }
1865  
1866 =head2 registerServiceWSDL
1867  
1868 Title : NOT YET IMPLEMENTED
1869 Usage :
1870  
1871  
1872 =cut
1873  
1874 sub registerServiceWSDL {
1875 my ( $pkg, $serviceType, $wsdl ) = @_;
1876 return &_error( "not yet implemented", "" );
1877 }
1878  
1879 =head2 deregisterService
1880  
1881 Title : deregisterService
1882 Usage : $REG = $MOBY->deregisterService($inputXML)
1883 Function : deregister a Service
1884 Returns : $REG object
1885 inputXML :
1886 <deregisterService>
1887 <authURI>biomoby.org</authURI>
1888 <serviceName>MyFirstService</serviceName>
1889 </deregisterService>
1890  
1891 ouptutXML : see Registration XML object
1892  
1893  
1894 =cut
1895  
1896 sub deregisterService {
1897 my ( $pkg, $payload ) = @_;
1898 $debug && &_LOG("\nstarting deregistration\n");
1899 my ( $authURI, $serviceName ) = &_deregisterServicePayload($payload);
1900 return &_error( "must provide an authority and a service name\n", "" )
1901 unless ( $authURI && $serviceName );
1902 return &_error("The service specified by authority=$authURI servicename=$serviceName does not exist in the registry","")
1903 unless (
1904 MOBY::service_instance->new(
1905 servicename => $serviceName,
1906 authority_uri => $authURI,
1907 test => 1
1908 ));
1909 my $SERVICE = MOBY::service_instance->new(
1910 servicename => $serviceName,
1911 authority_uri => $authURI
1912 );
1913 return &_error("service lookup failed for unknown reasons","") unless ($SERVICE);
1914  
1915 if ( $SERVICE->signatureURL ) {
1916 return &_error(
1917 "it is illegal to deregister a service that has a signatureURL. Such services must be deregistered by deleting the RDF at the location identified by the signatureURL",
1918 ""
1919 );
1920 }
1921  
1922 my $result = $SERVICE->DELETE_THYSELF;
1923 if ($result) {
1924 return &_success( "Service Deregistered Successfully", "" );
1925 }
1926 else {
1927 return &_error( "Service deletion failed for unknown reasons", "" );
1928 }
1929 }
1930  
1931 #Eddie - converted
1932 sub _deregisterServicePayload {
1933 my ($payload) = @_;
1934 $debug && &_LOG( "deregisterService payload: ", ($payload), "\n" );
1935 my $Parser = XML::LibXML->new();
1936 my $doc = $Parser->parse_string($payload);
1937 my $Object = $doc->getDocumentElement();
1938 my $obj = $Object->nodeName; #Eddie - unsure
1939 return undef unless ( $obj eq 'deregisterService' );
1940 my $authURI = &_nodeTextContent( $Object, "authURI" );
1941 my $name = &_nodeTextContent( $Object, "serviceName" );
1942 return ( $authURI, $name );
1943 }
1944  
1945 =head2 findService
1946  
1947 inputXML:
1948 <findService>
1949 <!-- Service Query Object -->
1950 </findService>
1951  
1952 ServiceQueryObject XML:
1953  
1954 To query MOBY Central, you fill out the relevant elements of a Query Ojbect. These include the input and/or output data Classes (by name from the Class ontology), the Service-type (by name from the Service-type ontology), the authority (service provider URI), or any number of keywords that must appear in the service description.
1955  
1956 =over 3
1957  
1958 =item * MOBY Central finds all services which match the contents of the Query Object.
1959  
1960 =item * All elements are optional, however at least one must be present.
1961  
1962 =item * All elements present are considered as increasingly limiting on the search (i.e. "AND").
1963  
1964 =item * keywords are:
1965  
1966 =over 3
1967  
1968 =item * comma-delimited
1969  
1970 =item * sentence-fragments are enclosed in double-quotes
1971  
1972 =item * wildcard "*" is allowed in combination with keyword fragments and or sentence fragments (lone "*" is meaningless and ignored)
1973  
1974 =item * multiple keywords are considered joined by "AND".
1975  
1976 =back
1977  
1978 =back
1979  
1980 In addition to the search parameters, there are two "flags" that can be set in the Query object:
1981  
1982 =over 3
1983  
1984 =item * expandServices: this flag will cause MOBY Central to traverse the Service ontology and discover services that are child types (more specific) than the Service-type you requested
1985  
1986 e.g. you might request "alignment", and it would discover services such as "Blast", "Smith Waterman", "Needleman Wunsch"
1987  
1988 =item * expandObjects: this flag will cause MOBY Central to traverse the Class ontology to find services that operate not only on the Object Class you are querying, but also any parent types or sub-objects of that Object Class.
1989  
1990 e.g. if you request services that work on AnnotatedSequence Objects this flag will also return services that work on Sequence objects, since AnnotatedSequence objects inherit from Sequence objects
1991  
1992 =back
1993  
1994 The Query object structure is as follows:
1995  
1996 <inputObjects>
1997 <Input>
1998 <!-- one or more Simple or Collection Primary articles -->
1999 </Input>
2000 </inputObjects>
2001 <outputObjects>
2002 <Output>
2003 <!-- one or more Simple or Collection Primary articles -->
2004 </Output>
2005 </outputObjects>
2006 <authoritative>1</authoritative>
2007 <Category>moby</Category>
2008 <serviceType>ServiceTypeTerm</serviceType>
2009 <serviceName>ServiceName</serviceName>
2010 <authURI>http://desired.service.provider</authURI>;
2011 <signatureURL>http://location.of.document/signature.rdf</signatureURL>
2012 <expandObjects>1|0</expandObjects>
2013 <expandServices>1|0</expandServices>
2014 <keywords>
2015 <keyword>something</keyword>
2016 ....
2017 ....
2018 </keywords>
2019  
2020  
2021 outputXML
2022  
2023 <Services>
2024 <Service authURI="authority.URI.here" serviceName="MyService" lsid="urn:lsid:authority.uri:serviceinstance:id">
2025 <serviceType lsid='urn:...'>Service_Ontology_Term</serviceType>
2026 <Protocol>moby</Protocol> <!-- or 'cgi' or 'soap' -->
2027 <authoritative>1</authoritative>
2028 <contactEmail>your@email.address</contactEmail>
2029 <URL>http://endpoint.of.service</URL>
2030 <Input>
2031 <!-- one or more Simple and/or Collection Primary articles -->
2032 </Input>
2033 <Output>
2034 <!-- one or more Simple and/or Collection Primary articles -->
2035 </Output>
2036 <secondaryArticles>
2037 <!-- one or more Secondary articles -->
2038 </secondaryArticles>
2039 <Description><![CDATA[free text description here]]></Description>
2040 </Service>
2041 ... <!-- one or more Service blocks may be returned -->
2042 ...
2043 ...
2044 </Services>
2045  
2046  
2047 =cut
2048  
2049 sub findService {
2050 $CONFIG ||= MOBY::Config->new; # exported by Config.pm
2051 my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
2052  
2053 my ( $pkg, $payload ) = @_;
2054 $debug && &_LOG("\nLOOKING FOR SERVICES\n");
2055 my %findme = &_findServicePayload($payload);
2056 $debug && &_LOG(
2057 "'serviceType' => $findme{serviceType},
2058 'authURI' => $findme{authURI},
2059 'servicename' => $findme{servicename},
2060 'expandObjects' => $findme{expandObjects},
2061 'expandServices' => $findme{expandServices},
2062 'authoritative' => $findme{authoritative},
2063 'category' => $findme{category},
2064 'signatureurl' => $findme{signatureURL},
2065 'keywords' => $findme{keywords},
2066 "
2067 );
2068 my %valid_service_ids;
2069 my $criterion_count = 0;
2070  
2071 # we want to avoid joins, since they slow things down, so...
2072 # the logic is that we keep a hash of valid id's
2073 # and the number of times they are discovered
2074 # we also count the number of criterion
2075 # we only want the service_id's that appear as many times as the criterion we have
2076 # since they will have matched every criterion.
2077  
2078 if ( $findme{authoritative} ) {
2079 ++$criterion_count;
2080 $debug
2081 && _LOG(
2082 "authoritative added; criterion count is now $criterion_count\n");
2083 my $ids = _extract_ids($adaptor->query_service_instance(authoritative => $findme{authoritative}));
2084
2085
2086
2087 ### MARK - we need to extract ids at each step...
2088
2089
2090
2091 unless ( scalar @{$ids} ) {
2092 return &_serviceListResponse(undef );
2093 }
2094 $debug
2095 && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" );
2096 foreach ( @{$ids} ) {
2097 $debug && &_LOG("found service_instance_id $_\n");
2098 ++$valid_service_ids{$_}; # increment that particular id's count by one
2099 }
2100 }
2101 if ( $findme{serviceType} ) { # must have something more than empty content
2102 my $OS = MOBY::OntologyServer->new( ontology => 'service' );
2103 $findme{serviceType} =~ s/^moby\://;
2104 my ( $exists, $message, $URI ) =
2105 $OS->serviceExists( term => $findme{serviceType} );
2106 unless ($exists) {
2107 return &_serviceListResponse(undef );
2108 }
2109 ++$criterion_count;
2110 $debug
2111 && _LOG(
2112 "serviceType added; criterion count is now $criterion_count\n");
2113 my $children_string = "'$URI',";
2114 if ( $findme{'expandServices'} ) {
2115 $debug && _LOG("Expanding Services\n");
2116 my $OS = MOBY::OntologyServer->new( ontology => 'service' );
2117 my %relationships = %{ $OS->traverseDAG( $URI, "leaves" ) };
2118 my (@children) =
2119 @{ $relationships{'urn:lsid:biomoby.org:servicerelation:isa'} };
2120 $children_string .= ( join ',', map { "\'$_\'" } @children );
2121 #*******FIX this isn't very perlish... sending a comma-delimited string to a subroutine instead of an array
2122 # need to change that one day soon!
2123 }
2124 $children_string =~ s/\,$//;
2125 my $ids = _extract_ids($adaptor->match_service_type_uri(service_type_uri => $children_string));
2126
2127 $debug
2128 && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" );
2129 foreach ( @{$ids} ) {
2130 $debug && &_LOG("found service_instance_id $_\n");
2131 ++$valid_service_ids{$_}; # increment that particular id's count by one
2132 }
2133 }
2134 if ( $findme{authURI} ) {
2135 ++$criterion_count;
2136 $debug
2137 && _LOG("authURI added; criterion count is now $criterion_count\n");
2138 my $ids = _extract_ids($adaptor->query_service_instance(authority_uri => $findme{'authURI'}));
2139  
2140 unless ( scalar @{$ids} ) {
2141 return &_serviceListResponse(undef );
2142 }
2143 $debug
2144 && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" );
2145 foreach ( @{$ids} ) {
2146 $debug && &_LOG("found service_instance_id $_\n");
2147 ++$valid_service_ids{$_}; # increment that particular id's count by one
2148 }
2149 }
2150 if ( $findme{signatureurl} ) {
2151 ++$criterion_count;
2152 $debug
2153 && _LOG("sigurl added; criterion count is now $criterion_count\n");
2154 my $ids = _extract_ids($adaptor->query_service_instance(signatureURL => $findme{'signatureurl'}));
2155  
2156 unless ( scalar @{$ids} ) {
2157 return &_serviceListResponse(undef );
2158 }
2159 $debug
2160 && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" );
2161 foreach ( @{$ids} ) {
2162 $debug && &_LOG("found service_instance_id $_\n");
2163 ++$valid_service_ids{$_}; # increment that particular id's count by one
2164 }
2165 }
2166 if ( $findme{servicename} ) {
2167 ++$criterion_count;
2168 $debug
2169 && _LOG(
2170 "servicename added; criterion count is now $criterion_count\n");
2171  
2172 my $ids = _extract_ids($adaptor->query_service_instance(servicename => $findme{servicename}));
2173  
2174 unless ( scalar @{$ids} ) {
2175 return &_serviceListResponse( undef );
2176 }
2177 $debug
2178 && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" );
2179 foreach ( @{$ids} ) {
2180 $debug && &_LOG("found service_instance_id $_\n");
2181 ++$valid_service_ids{$_}; # increment that particular id's count by one
2182 }
2183 }
2184
2185 if ( $findme{category} ) {
2186 ++$criterion_count;
2187 $debug
2188 && _LOG("category added; criterion count is now $criterion_count\n");
2189  
2190 my $ids = _extract_ids($adaptor->query_service_instance(category => lc( $findme{category}) ));
2191
2192 unless ( scalar @{$ids} ) {
2193 return &_serviceListResponse( undef );
2194 }
2195 $debug
2196 && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" );
2197 foreach ( @{$ids} ) {
2198 $debug && &_LOG("found service_instance_id $_\n");
2199 ++$valid_service_ids{$_}; # increment that particular id's count by one
2200 }
2201 }
2202 if ( $findme{keywords} && ( scalar @{ $findme{keywords} } ) ) {
2203 ++$criterion_count;
2204 $debug
2205 && _LOG("Keywords added; criterion count is now $criterion_count\n");
2206
2207 my ($ids) = $adaptor->check_keywords(keywords => \@{$findme{keywords}});
2208 $ids = _extract_ids($ids); # this is the hash-list that comes back from do_query
2209
2210 unless ( scalar @{$ids} ) {
2211 return &_serviceListResponse( undef );
2212 }
2213 $debug
2214 && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" );
2215 foreach ( @{$ids} ) {
2216 $debug && &_LOG("found service_instance_id $_\n");
2217 ++$valid_service_ids{$_}; # increment that particular id's count by one
2218 }
2219 }
2220 if ( $findme{inputObjects} && ( scalar @{ $findme{inputObjects} } ) ) {
2221 ++$criterion_count;
2222 $debug
2223 && _LOG(
2224 "inputObject added; criterion count is now $criterion_count\n");
2225 my $obj = ( shift @{ $findme{inputObjects} } );
2226 my @si_ids;
2227 @si_ids =
2228 &_searchForServicesWithArticle( "input", $obj,$findme{'expandObjects'}, '' )
2229 if defined $obj;
2230 $debug
2231 && _LOG("Initial Search For Services with INPUT Article found @si_ids\n");
2232 my %instances;
2233  
2234 # we need to do a join, without doing a join...
2235 if ( scalar @si_ids ) {
2236 map { $instances{$_} = 1 }
2237 @si_ids; # get an id of the good services from the first object
2238 while ( my $obj = shift( @{ $findme{inputObjects} } ) )
2239 { # iterate through the rest of the objects
2240 next unless $obj;
2241 $debug
2242 && _LOG( "FIRST: ", "input", $obj,
2243 $findme{'expandObjects'}, '' );
2244 my @new_ids =
2245 &_searchForServicesWithArticle("input", $obj,$findme{'expandObjects'}, '' ); # get their service ids
2246 $debug
2247 && _LOG("Subsequent Search For Services with INPUT Article found @new_ids\n");
2248 my @good_ids;
2249 my %good_ids;
2250 foreach my $id (@new_ids)
2251 { # check the new id set against the set we know is already valid
2252 next unless defined $id;
2253 if ( $instances{$id} ) {
2254 push @good_ids, $id;
2255 } # if they are in common, then that id is still good
2256 }
2257 map { $good_ids{$_} = 1 }
2258 @good_ids; # make a hash of the new good id's
2259 %instances = %good_ids
2260 ; # and replace the original list with this more limited one
2261 }
2262 }
2263  
2264 # now %instances contains only valid ID numbers
2265 $debug
2266 && _LOG( "Final results incremented of search for INPUT: "
2267 . ( join ',', ( keys %instances ) )
2268 . "\n" );
2269 foreach ( keys %instances ) {
2270 $debug && &_LOG("found id $_\n");
2271 ++$valid_service_ids{$_};
2272 }
2273 }
2274 if ( $findme{outputObjects} && ( scalar @{ $findme{outputObjects} } ) ) {
2275 ++$criterion_count;
2276 $debug
2277 && _LOG(
2278 "outputObject added; criterion count is now $criterion_count\n");
2279 my $obj = ( shift @{ $findme{outputObjects} } );
2280 my @si_ids;
2281 @si_ids = &_searchForServicesWithArticle("output", $obj, '' )if defined $obj;
2282 $debug
2283 && _LOG(
2284 "Initial Search For Services with OUTPUT Article found @si_ids\n");
2285 my %instances;
2286  
2287 # we need to do a join, without doing a join...
2288 if ( scalar @si_ids ) {
2289 map { $instances{$_} = 1 }
2290 @si_ids; # get an id of the good services from the first object
2291 while ( my $obj = shift( @{ $findme{outputObjects} } ) )
2292 { # iterate through the rest of the objects
2293 next unless $obj;
2294 my @new_ids =
2295 &_searchForServicesWithArticle("output", $obj, '' )
2296 ; # get their service ids
2297 $debug
2298 && _LOG("Subsequent Search For Services with OUTPUT Article found @new_ids\n"
2299 );
2300 my @good_ids;
2301 my %good_ids;
2302 foreach my $id (@new_ids)
2303 { # check the new id set against the set we know is already valid
2304 next unless defined $id;
2305 if ( $instances{$id} ) {
2306 push @good_ids, $id;
2307 } # if they are in common, then that id is still good
2308 }
2309 map { $good_ids{$_} = 1 }
2310 @good_ids; # make a hash of the new good id's
2311 %instances = %good_ids
2312 ; # and replace the original list with this more limited one
2313 }
2314 }
2315  
2316 # now %instances contains only valid ID numbers
2317 $debug
2318 && _LOG( "Final results incremented of search for OUTPUT: "
2319 . ( join ',', ( keys %instances ) )
2320 . "\n" );
2321 foreach ( keys %instances ) {
2322 $debug && &_LOG("found id $_\n");
2323 ++$valid_service_ids{$_};
2324 }
2325 }
2326 unless ($criterion_count){ # in case all criterion are null, find everything
2327 ++$criterion_count; # this is an AWFUL hack. We need to add a criterion in order for teh next while loop to be successful in finding each of these services. This is really really terrible, but it works until someone tries to "fix" something...
2328
2329 my $ids = _extract_ids($adaptor->query_service_instance(category => "IS NOT NULL" ));
2330 unless ( scalar @{$ids} ) {
2331 return &_serviceListResponse( undef );
2332 }
2333 foreach ( @{$ids} ) {
2334 $debug && &_LOG("found service_instance_id $_\n");
2335 ++$valid_service_ids{$_}; # increment that particular id's count by one
2336 }
2337 }
2338 my @final;
2339 while ( my ( $id, $freq ) = each %valid_service_ids ) {
2340 $debug
2341 && _LOG(
2342 "TALLY IS ID: $id FREQ:$freq\n CRITERION COUNT $criterion_count\n"
2343 );
2344 next
2345 unless $freq ==
2346 $criterion_count; # has to have matched every criterion
2347 push @final, $id;
2348 }
2349 return &_serviceListResponse(@final );
2350 }
2351  
2352 sub _extract_ids {
2353 my ($linehash) = @_;
2354 # ths data comes from the do_query of the mysql call
2355 # --> [{...}]
2356 my @lines = @$linehash;
2357 return [] unless scalar(@lines);
2358 my @ids;
2359 foreach (@lines){
2360 my $id = $_->{service_instance_id};
2361 push @ids, $id;
2362 }
2363 return \@ids
2364 }
2365  
2366 sub _how_exit {
2367 my ($exit) = @_;
2368 my ($status) = $exit >> 8;
2369 my ($signal) = $exit & 255;
2370 return $status unless $signal;
2371 return $signal;
2372 }
2373  
2374 #Eddie - converted
2375 sub _searchForServicesWithArticle {
2376 my ($inout, $node, $expand, $coll ) = @_;
2377 return ()
2378 unless $node->nodeType ==
2379 ELEMENT_NODE; # this will erase all current successful service instances!
2380 $debug
2381 && _LOG( "searchServWthArticle ", $inout, $node, $expand, $coll );
2382  
2383 # this element node may be a Simple or a Collection object
2384 my $simp_coll = $node->nodeName;
2385 $debug && &_LOG("TAGNAME in _searchForArticle is $simp_coll");
2386 my @valid_ids;
2387 if ( $simp_coll eq "Collection" ) {
2388 @valid_ids = &_searchForCollection( $node, $expand, $inout );
2389 }
2390 elsif ( $simp_coll eq "Simple" ) {
2391 @valid_ids = &_searchForSimple( $node, $expand, $inout );
2392 }
2393 return @valid_ids;
2394 }
2395  
2396 sub _searchForSimple {
2397 $CONFIG ||= MOBY::Config->new; # exported by Config.pm
2398 my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
2399  
2400 # returns list of service_instance ID's
2401 # that match this simple
2402 my ( $node, $expand, $inout ) = @_;
2403 $debug && _LOG( $node, $expand, $inout );
2404 my ( $objectURI, $namespaceURIs ) =
2405 &_extractObjectTypesAndNamespaces($node); # (objectType, [ns1, ns2, ns3])
2406 unless ($objectURI) { return () }
2407 my $ancestor_string = "'$objectURI',";
2408 if ($expand) {
2409 $debug && _LOG("Expanding Objects\n");
2410 my $OS = MOBY::OntologyServer->new( ontology => 'object' );
2411 my %relationships = %{ $OS->traverseDAG( $objectURI, "root" ) };
2412 my (@ancestors) =
2413 @{ $relationships{'urn:lsid:biomoby.org:objectrelation:isa'} };
2414 $ancestor_string .= ( join ',', map { "\'$_\'" } @ancestors );
2415 }
2416 $ancestor_string =~ s/\,$//;
2417
2418 my $result = $adaptor->find_by_simple(inout => $inout,
2419 ancestor_string => $ancestor_string,
2420 namespaceURIs => $namespaceURIs);
2421  
2422 my @valid_services;
2423
2424 foreach my $row (@$result)
2425 {
2426 # get the service instance ID and the namespaces that matched
2427 my $id = $row->{service_instance_id};
2428 my $nss = $row->{namespace_type_uris};
2429 if ( $nss && scalar @{$namespaceURIs} )
2430 { # if this service cares about namespaces at all,
2431 # and if namespaces were specified in the query,
2432 # then validate the discovered service against this list
2433 my @ns = split ",", $nss
2434 ; # because of the database structure we have to re-test for *identity*, not just like%% similarity
2435 my %nshash = map { ( $_, 1 ) } @ns, @{ $namespaceURIs
2436 }; #we're going to test identity by building a hash of namespaces as keys
2437 if (
2438 scalar( keys %nshash ) <
2439 scalar(@ns) + scalar( @{$namespaceURIs} ) )
2440 { # if the number of keys is less than the sum of the number of keys goign into the hash, then one of them was identical
2441 push @valid_services,
2442 $id; # and therefore it really is a match, and is valid
2443 }
2444 }
2445 else { # if no namespace was specified, then all of them are valid
2446 push @valid_services, $id;
2447 }
2448 }
2449 $debug
2450 && _LOG( "Resulting IDs were " . ( join ',', @valid_services ) . "\n" );
2451 return @valid_services;
2452 }
2453  
2454 #Eddie - converted
2455 sub _searchForCollection {
2456 $CONFIG ||= MOBY::Config->new; # exported by Config.pm
2457 my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
2458  
2459 my ( $node, $expand, $inout ) =
2460 @_; # $node in this case is a Collection object
2461  
2462 # luckily, we can return a redundant list of service id's and
2463 # this will be cleaned up in the caller
2464 my @validservices;
2465 foreach my $simple ( $node->childNodes() ) {
2466 next unless ( $simple->nodeType == ELEMENT_NODE );
2467 next unless ( $simple->nodeName =~ /simple/i );
2468 my ( $objectURI, $namespaceURIs ) =
2469 &_extractObjectTypesAndNamespaces($simple);
2470  
2471 my $result = $adaptor->find_by_collection(inout => $inout,
2472 objectURI => $objectURI,
2473 namespaceURIs => $namespaceURIs);
2474  
2475 foreach my $row (@$result )
2476 { # get the service instance ID and the namespaces that matched
2477 my $id = $row->{service_instance_id};
2478 my $nss = $row->{namespace_type_uris};
2479 if ( $nss && scalar @{$namespaceURIs} )
2480 { # if this service cares about namespaces at all,
2481 # and if namespaces were specified in the query,
2482 # then validate the discovered service against this list
2483 my @ns = split ",", $nss
2484 ; # because of the database structure we have to re-test for *identity*, not just like%% similarity
2485 my %nshash = map { ( $_, 1 ) } @ns, @{ $namespaceURIs
2486 }; #we're going to test identity by building a hash of namespaces as keys
2487 if (
2488 scalar( keys %nshash ) <
2489 scalar(@ns) + scalar( @{$namespaceURIs} ) )
2490 { # if the number of keys is less than the sum of the number of keys goign into the hash, then one of them was identical
2491 push @validservices,
2492 $id; # and therefore it really is a match, and is valid
2493 }
2494 }
2495 else { # if no namespace was specified, then all of them are valid
2496 push @validservices, $id;
2497 }
2498 }
2499 }
2500 return @validservices;
2501 }
2502  
2503 #Eddie - converted
2504 sub _findServicePayload {
2505 my ($payload) = @_;
2506 my $Parser = XML::LibXML->new();
2507 my $doc = $Parser->parse_string($payload);
2508 my $Object = $doc->getDocumentElement();
2509 my $obj = $Object->nodeName;
2510 return undef unless ( $obj eq 'findService' );
2511 my $serviceType = &_nodeTextContent( $Object, "serviceType" );
2512 $serviceType && ( $serviceType =~ s/\s+//g );
2513 my $servicename = &_nodeTextContent( $Object, "serviceName" );
2514 $servicename && ( $servicename =~ s/\s+//g );
2515 my $authoritative = &_nodeTextContent( $Object, "authoritative" );
2516 $authoritative && ( $authoritative =~ s/\s+//g );
2517 my $Category = &_nodeTextContent( $Object, "Category" );
2518 $Category && ( $Category =~ s/\s+//g );
2519 my $AuthURI = &_nodeTextContent( $Object, "authURI" );
2520 $AuthURI && ( $AuthURI =~ s/\s+//g );
2521
2522 # add signatureURL to the list of things to find
2523 my $signatureURL = &_nodeTextContent( $Object, "signatureURL" );
2524 $signatureURL && ( $signatureURL =~ s/\s+//g );
2525
2526 my $expandObjects = &_nodeTextContent( $Object, "expandObjects" );
2527 $expandObjects && ( $expandObjects =~ s/\s+//g );
2528 my $expandServices = &_nodeTextContent( $Object, "expandServices" );
2529 $expandServices && ( $expandServices =~ s/\s+//g );
2530 my @kw = &_nodeArrayContent( $Object, "keywords" );
2531 my $INPUTS = &_nodeRawContent( $Object, "Input" ); # returns array ref
2532 my $OUTPUTS = &_nodeRawContent( $Object, "Output" ); # returns array ref
2533 return (
2534 'serviceType' => $serviceType,
2535 'authURI' => $AuthURI,
2536 'signatureurl' => $signatureURL,
2537 'servicename' => $servicename,
2538 'expandObjects' => $expandObjects,
2539 'expandServices' => $expandServices,
2540 'authoritative' => $authoritative,
2541 'category' => $Category,
2542 'inputObjects' => $INPUTS,
2543 'outputObjects' => $OUTPUTS,
2544 'keywords' => \@kw
2545 );
2546 }
2547  
2548 #Eddie - converted
2549 sub _extractObjectTypesAndNamespaces {
2550  
2551 # takes a SINGLE simple article and return regular list ($objectURI, [nsURI1, nsURI2, nsURI3])
2552 my ($DOM) = @_;
2553 $debug
2554 && &_LOG(
2555 "\n\n_extractObjectTypesAndNamespaces\nExtracting object types from \n$DOM \n\n"
2556 );
2557 unless ( ref($DOM) =~ /^XML/ ) {
2558 my $Parser = XML::LibXML->new();
2559 my $doc = $Parser->parse_string($DOM);
2560 $DOM = $doc->getDocumentElement();
2561 }
2562 my $x = $DOM->getElementsByTagName("objectType");
2563 my $objectname;
2564 my @child = $x->get_node(1)->childNodes;
2565 foreach (@child) {
2566 $debug && &_LOG( getNodeTypeName($_), "\t", $_->toString, "\n" );
2567 next unless ( $_->nodeType == TEXT_NODE );
2568 my $name = $_->toString;
2569 chomp $name;
2570 $objectname = $name;
2571 }
2572 $objectname =~ s/^moby\://
2573 ; # damn XML DOM can't deal with namespaces... so get rid of it if it exists, though this is going to limit us to only MOBY objects again :-(
2574 my $OS = MOBY::OntologyServer->new( ontology => 'object' );
2575 my ( $exists, $message, $objectURI ) =
2576 $OS->objectExists( term => $objectname );
2577 return ( undef, [] ) unless $objectURI;
2578 my $ns = $DOM->getElementsByTagName("Namespace");
2579 my @namespaces;
2580 my $nonamespaces = $ns->size();
2581 $OS = MOBY::OntologyServer->new( ontology => 'namespace' );
2582  
2583 for ( my $n = 1 ; $n <= $nonamespaces ; ++$n ) {
2584 my @child = $ns->get_node($n)->childNodes;
2585 foreach (@child) {
2586 $debug && &_LOG( getNodeTypeName($_), "\t", $_->toString, "\n" );
2587 next unless ( $_->nodeType == TEXT_NODE );
2588 my $name = $_->toString;
2589 chomp $name;
2590 my ( $success, $message, $URI ) =
2591 $OS->namespaceExists( term => $name );
2592 $URI
2593 ? ( push @namespaces, $URI )
2594 : ( push @namespaces, "__MOBY__INVALID__NAMESPACE__" );
2595 }
2596 }
2597 return ( $objectURI, \@namespaces );
2598 }
2599  
2600 =head2 retrieveService
2601  
2602 Title : retrieveService
2603 Usage : $WSDL = $MOBY->retrieveService($inputXML)
2604 Function : get the WSDL descriptions for services with this service name
2605 Returns : XML (see below)
2606 Comment : the WSDL that you get back is invalid w.r.t. the object structure
2607 It will always be so.
2608 It should be used only to create stubs for the connection to the service.
2609 inputXML :
2610 <retrieveService>
2611 <Service authURI="authority.uri.here" serviceName="myServ"/>
2612 <retrieveService>
2613  
2614 outputXML (by category):
2615  
2616 moby: <Service lsid='urn:lsid:...'><![CDATA[WSDL document here]]</Service>
2617  
2618  
2619 =cut
2620  
2621 sub retrieveService {
2622 my ( $pkg, $payload ) = @_;
2623 my ( $AuthURI, $serviceName, $InputXML, $OutputXML, $SecondaryXML ) =
2624 &_retrieveServicePayload($payload);
2625 unless ( $AuthURI && $serviceName ) { return "<Services/>" }
2626 my $SI = MOBY::service_instance->new(
2627 authority_uri => $AuthURI,
2628 servicename => $serviceName
2629 );
2630 my $servlsid = $SI->lsid;
2631 my $wsdls;
2632 return "<Services/>" unless ($SI);
2633 &listener(authority => $AuthURI, servicename => $serviceName); # log the requst for research purposes
2634 my $wsdl = &_getServiceWSDL( $SI, $InputXML, $OutputXML, $SecondaryXML );
2635 if ($wsdl) {
2636 if ( $wsdl =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
2637 $wsdl = $1;
2638 }
2639 $wsdls .= "<Service lsid='$servlsid'><![CDATA[$wsdl]]></Service>\n";
2640 }
2641
2642 #$debug && &_LOG("WSDL_________________$wsdls\n____________________");
2643 return $wsdls;
2644 }
2645  
2646 #Eddie - converted
2647 sub _retrieveServicePayload {
2648 my ($payload) = @_;
2649 my $Parser = XML::LibXML->new();
2650 my $doc = $Parser->parse_string($payload);
2651 my $x = $doc->getElementsByTagName("Service");
2652 my $authURI = "";
2653 my $serviceName = "";
2654 my $l = $x->size(); # might be a Collection object with multiple simples...
2655 for ( my $n = 1 ; $n <= $l ; ++$n ) {
2656 $authURI =
2657 $x->get_node($n)->getAttributeNode("authURI")
2658 ; # may or may not have a name
2659 if ($authURI) { $authURI = $authURI->getValue() }
2660 $serviceName =
2661 $x->get_node($n)->getAttributeNode("serviceName")
2662 ; # may or may not have a name
2663 if ($serviceName) { $serviceName = $serviceName->getValue() }
2664 }
2665 my $INPUT = $doc->getElementsByTagName("Input");
2666 my $InputXML = "";
2667 if ( $INPUT->get_node(1) ) {
2668 $InputXML = $INPUT->get_node(1)->toString;
2669 }
2670 my $OUTPUT = $doc->getElementsByTagName("Output");
2671 my $OutputXML = "";
2672 if ( $OUTPUT->get_node(1) ) {
2673 $OutputXML = $OUTPUT->get_node(1)->toString;
2674 }
2675 my $SECONDARY = $doc->getElementsByTagName("Output");
2676 my $SecondaryXML = "";
2677 if ( $SECONDARY->get_node(1) ) {
2678 $SecondaryXML = $SECONDARY->get_node(1)->toString;
2679 }
2680 return ( $authURI, $serviceName, $InputXML, $OutputXML, $SecondaryXML );
2681 }
2682  
2683 =head2 retrieveResourceURLs
2684  
2685 Title : retrieveResourceURLs
2686 Usage : $urls = $MOBY->retrieveResourceURLs
2687 Function : to retrieve the location(s) of the RDF versions of the various
2688 MOBY-S Ontologies
2689 Args : none
2690 Returns : XML (see below). The "name" attribute indicates which ontology
2691 is described by the URL (Service, Object, Namespace, ServiceInstance, Full),
2692 and the "url" attribute provides a URL that, when called with an
2693 HTTP GET, will return RDF-XML describing that ontology.
2694 XML :
2695 <resourceURLs>
2696 <Resource name="Service" url="http://mobycentral.org/RESOURCES/MOBY-S/Services/>
2697 <Resource name="Object" url="..."/>
2698 <Resource name="Namespace" url="...X..."/>
2699 <Resource name="Namespace" url="...Y..."/>
2700 </resourceURLs>
2701  
2702 =cut
2703  
2704 sub retrieveResourceURLs {
2705  
2706 $CONFIG ||= MOBY::Config->new; # exported by Config.pm
2707 my $central = $CONFIG->{mobycentral}->{resourceURL};
2708 my $service = $CONFIG->{mobyservice}->{resourceURL};
2709 my $namespace = $CONFIG->{mobynamespace}->{resourceURL};
2710 my $object = $CONFIG->{mobyobject}->{resourceURL};
2711 my $all = $CONFIG->{mobycentral}->{allResources};
2712  
2713 my $message ="<resourceURLs>";
2714 $message .="<Resource name='ServiceInstance' url='$central'/>" if $central;
2715 $message .="<Resource name='Object' url='$object'/>" if $object;
2716 $message .="<Resource name='Service' url='$service'/>" if $service;
2717 $message .="<Resource name='Namespace' url='$namespace'/>" if $namespace;
2718 $message .="<Resource name='Full' url='$all'/>" if $all;
2719 $message .="</resourceURLs>";
2720 return $message;
2721 }
2722
2723
2724 =head2 retrieveServiceProviders
2725  
2726 Title : retrieveServiceProviders
2727 Usage : $uris = $MOBY->retrieveServiceProviders()
2728 Function : get the list of all provider's AuthURI's
2729 Returns : XML (see below)
2730 Args : none
2731 XML :
2732 <serviceProviders>
2733 <serviceProvider name="authority.info.here"/>
2734 ...
2735 ...
2736 </serviceProviders>
2737  
2738 =cut
2739  
2740 sub retrieveServiceProviders {
2741 $CONFIG ||= MOBY::Config->new; # exported by Config.pm
2742 my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
2743  
2744 my ($pkg) = @_;
2745  
2746 my $result = $adaptor->get_all_authorities();
2747  
2748 my $providers = "<serviceProviders>\n";
2749 foreach my $prov (@$result) {
2750 $providers .= "<serviceProvider name='".($prov->{authority_uri})."'/>\n";
2751 }
2752 $providers .= "</serviceProviders>\n";
2753 return $providers;
2754 }
2755  
2756 =head2 retrieveServiceNames
2757  
2758 Title : retrieveServiceNames
2759 Usage : $names = $MOBY->retrieveServiceNames()
2760 Function : get a (redundant) list of all registered service names
2761 (N.B. NOT service types!)
2762 Returns : XML (see below)
2763 Args : none
2764 XML :
2765 <serviceNames>
2766 <serviceName name="serviceName" authURI='authority.info.here' lsid = 'urn:lsid...'/>
2767 ...
2768 ...
2769 </serviceNames>
2770  
2771 =cut
2772  
2773 sub retrieveServiceNames {
2774 $CONFIG ||= MOBY::Config->new; # exported by Config.pm
2775 my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
2776  
2777 my ($pkg) = shift;
2778  
2779 my $result = $adaptor->get_service_names();
2780 my $names = "<serviceNames>\n";
2781 foreach my $row (@$result) {
2782 my $name = $row->{servicename};
2783 my $auth = $row->{authority_uri};
2784 my $lsid = $row->{lsid};
2785 $names .= "<serviceName name='$name' authURI='$auth' lsid='$lsid'/>\n";
2786 }
2787 $names .= "</serviceNames>\n";
2788 return $names;
2789 }
2790  
2791 =head2 retrieveServiceTypes
2792  
2793 Title : retrieveServiceTypes
2794 Usage : $types = $MOBY->retrieveServiceTypes()
2795 Function : get the list of all registered service types
2796 Returns : XML (see below)
2797 Args : none
2798 XML :
2799 <serviceTypes>
2800 <serviceType name="serviceTypeName" lsid="urn:lsid...">
2801 <Description><![CDATA[free text description here]]></Description>
2802 <contactEmail>your@email.here</contactEmail>
2803 <authURI>authority.uri.here</authURI>
2804 <ISA lsid="urn:lsid...">parentTypeName</ISA> <!-- both empty for root Service! -->
2805 </serviceType>
2806 ...
2807 ...
2808 </serviceTypes>
2809  
2810 =cut
2811  
2812 sub retrieveServiceTypes {
2813 my ($pkg) = @_;
2814 my $OS = MOBY::OntologyServer->new( ontology => 'service' );
2815 my %types = %{ $OS->retrieveAllServiceTypes() };
2816 my $types = "<serviceTypes>\n";
2817 while ( my ( $serv, $descr ) = each %types ) { #UNCOMMENT
2818 my ($desc, $lsid, $contact, $auth, $isa_type, $isa_lsid) = @$descr;
2819 if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
2820 $desc = $1;
2821 }
2822 $isa_type ||="";
2823 $isa_lsid ||="";
2824 $types .="<serviceType name='$serv' lsid='$lsid'>
2825 <Description><![CDATA[$desc]]></Description>
2826 <contactEmail>$contact</contactEmail>
2827 <authURI>$auth</authURI>
2828 <ISA lsid='$isa_lsid'>$isa_type</ISA>
2829 </serviceType>\n"; #UNCOMMENT
2830 }
2831 $types .= "</serviceTypes>\n";
2832 return $types;
2833 }
2834  
2835 =head2 retrieveRelationshipTypes
2836  
2837 Title : retrieveRelationshipTypes
2838 Usage : $types = $MOBY->retrieveRelationshipTypes($xml)
2839 Function : get the list of all registered relationship types in the given ontology
2840 Returns : XML (see below)
2841 Args : input XML (ontologies are 'object', 'service', 'namespace', 'relationship')
2842  
2843 Input XML : <Ontology>OntologyName</Ontology>
2844 Output XML:
2845 <relationshipTypes>
2846 <relationshipType relationship="ontologyterm" authority="biomoby.org">
2847 <Description><![CDATA[free text description here]]></Description>
2848 </relationshipType>
2849 ...
2850 ...
2851 </relationshipTypes>
2852  
2853 =cut
2854  
2855 #Eddie - converted
2856 sub retrieveRelationshipTypes {
2857 my ( $pkg, $payload ) = @_;
2858 my $Parser = XML::LibXML->new();
2859 my $doc = $Parser->parse_string($payload);
2860 my $ontology = &_nodeTextContent( $doc, "Ontology" );
2861 my $OS = MOBY::OntologyServer->new( ontology => 'relationship' );
2862 my %types = %{ $OS->getRelationshipTypes( ontology => $ontology ) };
2863 my $types = "<relationshipTypes>\n";
2864 while ( my ( $lsid, $authdesc ) = each %types ) {
2865 my $name = $authdesc->[0];
2866 my $auth = $authdesc->[1];
2867 my $desc = $authdesc->[2];
2868 if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
2869 $desc = $1;
2870 }
2871 $types .="<relationshipType relationship='$name' authority='$auth' lsid='$lsid'>\n<Description><![CDATA[$desc]]></Description>\n</relationshipType>\n";
2872 }
2873 $types .= "</relationshipTypes>\n";
2874 return $types;
2875 }
2876  
2877 =head2 retrieveObjectNames
2878  
2879 Title : retrieveObjectNames
2880 Usage : $names = $MOBY->retrieveObjectNames()
2881 Function : get the list of all registered Object types
2882 Returns : XML (see below)
2883 Args : none
2884 XML :
2885 <objectNames>
2886 <Object name="objectName" lsid="urn:lsid:...">
2887 <Description><![CDATA[free text description here]]></Description>
2888 </Object>
2889 ...
2890 ...
2891 </objectNames>
2892  
2893 =cut
2894  
2895 sub retrieveObjectNames {
2896 my ($pkg) = @_;
2897 my $OS = MOBY::OntologyServer->new( ontology => 'object' );
2898 my %types = %{ $OS->retrieveAllObjectTypes() };
2899 my $obj = "<objectNames>\n";
2900 while ( my ( $name, $descr ) = each %types ) {
2901 my ($desc, $lsid) = @$descr;
2902 if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
2903 $desc = $1;
2904 }
2905 $obj .="<Object name='$name' lsid='$lsid'>\n<Description><![CDATA[$desc]]></Description>\n</Object>\n";
2906 }
2907 $obj .= "</objectNames>\n";
2908 return $obj;
2909 }
2910  
2911 =head2 retrieveObjectDefinition
2912  
2913 Title : retrieveObjectDefinition
2914 Usage : $registerObjectXML = $MOBY->retrieveObjectDefinition($inputXML)
2915 Function : get the full description of an object, as registered
2916 Returns : see input XML for registerObjectClass
2917 Input XML :
2918 <retrieveObjectDefinition>
2919 <obqjectType>ExistingObjectClassname</objectType>
2920 </retrieveObjectDefinition>
2921  
2922 Ouptut XML :
2923 <retrieveObjectDefinition>
2924 <objectType lsid="urn:lsid:...">NewObjectType</objectType>
2925 <Description><![CDATA[
2926 human readable description
2927 of data type]]>
2928 </Description>
2929 <Relationship relationshipType="urn:lsid...">
2930 <objectType articleName="SomeName" lsid="urn:lsid...">ExistingObjectType</objectType>
2931 </Relationship>
2932 ...
2933 ...
2934 <authURI>owner.URI.here</authURI>
2935 <contactEmail>owner@their.address.com</contactEmail>
2936 </retrieveObjectDefinition>
2937  
2938  
2939 =cut
2940  
2941 #Eddie - converted
2942 sub retrieveObjectDefinition {
2943 my ( $pkg, $payload ) = @_;
2944 my $Parser = XML::LibXML->new();
2945 my $doc = $Parser->parse_string($payload);
2946 my $term = &_nodeTextContent( $doc, "objectType" );
2947 return "<retrieveObjectDefinition/>" unless $term;
2948 my $OS = MOBY::OntologyServer->new( ontology => 'object' );
2949 my $def =
2950 $OS->retrieveObject( node => $term )
2951 ; # will return undef if this term does not exist, and does not look like an LSID
2952 return "<retrieveObjectDefinition/>" unless $def;
2953 my %def = %{ $OS->retrieveObject( type => $term ) };
2954  
2955 if ( $def{description} =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
2956 $def{description} = $1;
2957 }
2958  
2959 my $response;
2960 $response = "<retrieveObjectDefinition>
2961 <objectType lsid='$def{objectLSID}'>$def{objectType}</objectType>
2962 <Description><![CDATA[$def{description}]]></Description>
2963 <authURI>$def{authURI}</authURI>
2964 <contactEmail>$def{contactEmail}</contactEmail>\n";
2965 my %relationships = %{ $def{Relationships} };
2966
2967 while ( my ( $rel, $objdefs ) = each %relationships ) {
2968 $response .= "<Relationship relationshipType='$rel'>\n";
2969 foreach my $def ( @{$objdefs} ) {
2970 my ( $lsid, $articlename,$type, $def, $auth, $contac ) = @{$def};
2971 $articlename = "" unless defined $articlename;
2972 $response .=
2973 "<objectType articleName='$articlename' lsid='$lsid'>$type</objectType>\n";
2974 }
2975 $response .= "</Relationship>\n";
2976 }
2977 $response .= "</retrieveObjectDefinition>\n";
2978 return $response;
2979 }
2980  
2981 =head2 retrieveNamespaces
2982  
2983 Title : retrieveNamespaces
2984 Usage : $ns = $MOBY->retrieveNamespaces()
2985 Function : get the list of all registered Object types
2986 Returns : XML (see below)
2987 Args : none
2988 XML :
2989 <Namespaces>
2990 <Namespace name="namespace" lsid="urn:lsid:...">
2991 <Description><![CDATA[free text description here]]></Description>
2992 <contactEmail>email@address.here</contactEmail>
2993 <authURI>authority.uri.here</authURI>
2994 </Namespace>
2995 ...
2996 ...
2997 </Namespaces>
2998  
2999 =cut
3000  
3001 sub retrieveNamespaces {
3002 my ($pkg) = @_;
3003 my $OS = MOBY::OntologyServer->new( ontology => 'namespace' );
3004 my %types = %{ $OS->retrieveAllNamespaceTypes() };
3005 my $ns = "<Namespaces>\n";
3006 while ( my ( $namespace, $descr ) = each %types ) {
3007 my ($desc, $lsid, $auth, $contact) = @$descr;
3008 if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
3009 $desc = $1;
3010 }
3011 # $ns .= "<Namespace name='$namespace' lsid='$lsid'>\n<Description><![CDATA[$desc]]></Description>\n</Namespace>\n"; #COMMENT/REMOVE
3012 $ns .= "<Namespace name='$namespace' lsid='$lsid'>\n<Description><![CDATA[$desc]]></Description>\n<contactEmail>$contact</contactEmail>\n<authURI>$auth</authURI>\n</Namespace>\n";#UNCOMMENT
3013 }
3014 $ns .= "</Namespaces>";
3015 return $ns;
3016 }
3017  
3018 =head2 retrieveObject
3019  
3020 NOT YET IMPLEMENTED
3021 Title : retrieveObject
3022 Usage : $objects = $MOBY->retrieveObject($inputXML)
3023 Function : get the object xsd
3024 Returns : XML (see below)
3025 Args : $name - object name (from ontology) or "all" to get all objects
3026  
3027 inputXML :
3028 <retrieveObject>
3029 <objectType>ObjectType | all</objectType>
3030 </retrieveObject>
3031  
3032 outputXML :
3033 <Objects>
3034 <Object name="namespace">
3035 <Schema><XSD schema fragment here></Schema>
3036 </Object>
3037 ...
3038 ...
3039 </Objects>
3040  
3041 =cut
3042  
3043 sub retrieveObject {
3044 my ( $pkg, $payload ) = @_;
3045 my $response = "<Objects>\n";
3046 $response .= "<NOT_YET_IMPLEMENTED/>\n";
3047 $response .= "</Objects>\n";
3048 return $response;
3049 }
3050  
3051 #Eddie - converted
3052 sub _retrieveObjectPayload {
3053 my ($payload) = @_;
3054 my $Parser = XML::LibXML->new();
3055 my $doc = $Parser->parse_string($payload);
3056 my $Object = $doc->getDocumentElement();
3057 my $obj = $Object->nodeName;
3058 return undef unless ( $obj eq 'retrieveObject' );
3059 my $type = &_nodeTextContent( $Object, "objectType" );
3060 return ($type);
3061 }
3062  
3063 =head2 Relationships
3064  
3065 Title : Relationships
3066 Usage : $ns = $MOBY->Relationships()
3067 Function : get the fist level of relationships for the given term
3068 Returns : output XML (see below)
3069 Args : Input XML (see below).
3070 Notes : expandRelationships behaviour
3071 - for ISA relationships means traverse to root/leaves
3072 - for HAS and HASA means traverse ISA to root/leaves and
3073 for each node in the ISA hierarchy return the HAS/HASA
3074 relationship partners, where 'root' matches container objects
3075 and 'leaves' matches contained objects.
3076 Example: suppose a relationship "objA HAS objB",
3077 a) if query is objectType=>objA, direction=>'root', relationship=>'HAS',
3078 then objB is in result set
3079 b) if query is objectType=>objB, direction=>'leaves', relationship=>'HAS',
3080 then objA is in result set
3081  
3082 input XML :
3083 <Relationships>
3084 <objectType>$term</objectType>
3085 <expandRelationship>1|0</expandRelationship>
3086 <direction>root|leaves</direction>
3087 <relationshipType>$relationship_term</relationshipType>
3088 ... more relationship types
3089 ...
3090 </Relationships>
3091 OR
3092 <Relationships>
3093 <serviceType>$term</serviceType>
3094 <expandRelationship>1|0</expandRelationship>
3095 <direction>root|leaves</direction>
3096 <relationshipType>$relationship_term</relationshipType>
3097 ... more relationship types
3098 ...
3099 </Relationships>
3100  
3101  
3102 outputXML :
3103 <Relationships>
3104 <Relationship relationshipType="RelationshipOntologyTerm">
3105 <objectType lsid='urn:lsid...'>ExistingObjectType</objectType>
3106 <objectType lsid='urn:lsid...'>ExistingObjectType</objectType>
3107 </Relationship>
3108 <Relationship relationshipType="AnotherRelationshipTerm">
3109 ....
3110 </Relationship>
3111 </Relationships>
3112  
3113 OR
3114  
3115 <Relationships>
3116 <Relationship relationshipType="RelationshipOntologyTerm">
3117 <serviceType lsid='urn:lsid...'>ExistingServiceType</serviceType>
3118 <serviceType lsid='urn:lsid...'>ExistingServiceType</serviceType>
3119 </Relationship>
3120 <Relationship relationshipType="AnotherRelationshipTerm">
3121 ....
3122 </Relationship>
3123 </Relationships>
3124  
3125  
3126 =cut
3127  
3128 sub Relationships {
3129 my ( $pkg, $payload ) = @_;
3130 my $ontology;
3131 my $Parser = XML::LibXML->new();
3132 my $doc = $Parser->parse_string($payload);
3133 my $x = $doc->getElementsByTagName("relationshipType");
3134 my $l = $x->size();
3135 my $exp = $doc->getElementsByTagName("expandRelationship");
3136 my $expl = $exp->size();
3137 my $expand_relationship = &_nodeTextContent( $doc, 'expandRelationship' );
3138 $expand_relationship =~ s/\s//g;
3139 $expand_relationship ||= 0;
3140  
3141
3142 # find out direction:
3143 my $direction = &_nodeTextContent( $doc, "direction" );
3144 $direction = 'root' unless $direction; # make root default to stay compatible
3145 # it has to be either 'leaves' or 'root'
3146 $direction = ($direction eq 'leaves') ? 'leaves' : 'root';
3147
3148
3149 my %reltypes;
3150 my $relationship;
3151  
3152  
3153
3154 for ( my $n = 1 ; $n <= $l ; ++$n ) {
3155 my @child = $x->get_node($n)->childNodes;
3156 foreach (@child) {
3157 next unless ( $_->nodeType == TEXT_NODE );
3158 my $name .= $_->toString;
3159 $name =~ s/\s//g;
3160 $reltypes{$name} = 1; # make a hash of desired relationship types $reltypes{isa}=1; $reltypes{hasa}=1, etc
3161 }
3162 }
3163  
3164 # are we working on a service or an object?
3165 my $term = &_nodeTextContent( $doc, "objectType" );
3166 $ontology = "object" if $term; # pick up the ontology "object" that we used here if we got an object term
3167 $term ||= &_nodeTextContent( $doc, "serviceType" ); # if we didn't get anything using objectType try serviceType
3168 return undef unless $term; # and bail out if we didn't succeed
3169 $ontology ||= "service"; # if we have now succeeded and haven't already taken the ontology then it must be the service ontology
3170 $debug && &_LOG("Ontology was $ontology; Term was $term\n");
3171  
3172 ## replace $reltypes{isa}=1 with $reltypes{urn:lsid:...:isa}= 1
3173 #foreach ( keys %reltypes ) { # for each of our desired types
3174 # my $rellsid = $OSrel->getRelationshipURI( $ontology, $_ ); # get the LSID
3175 # delete $reltypes{$_}; # remove the non-LSID version from the hash
3176 # $reltypes{$rellsid} = 1; # set the LSID as valid
3177 #}
3178  
3179  
3180 my $response = "<Relationships>\n"; # outermost tag containing individual relationship blocks
3181  
3182 my %relationships_found; # the final list of discovered relationships
3183 my $OS = MOBY::OntologyServer->new( ontology => $ontology );
3184  
3185 foreach $relationship(keys %reltypes){ # we are going to concatenate the hashes here; keys are "ISA", "HASA", etc
3186 %relationships_found =(%relationships_found, %{ $OS->Relationships( # concatentate (%a,%b) --> %rels = $rels{relationship_lsid} = [lsid, lsid,lsid]
3187 term => $term,
3188 expand => $expand_relationship,
3189 relationship => $relationship,
3190 direction => $direction,
3191 )}); # %relationships_found = $rels{relationship_lsid} = [lsid, lsid,lsid]
3192 }
3193
3194
3195 my $OSrel = MOBY::OntologyServer->new( ontology => 'relationship' );
3196 # now for each of the relationship types that we were returned
3197 foreach my $this_rel( keys %reltypes ) { # keys are "isa" or "hasa"...
3198 my $rellsid = $OSrel->getRelationshipURI( $ontology, $this_rel ); # convert ISA to urn:lsid...:isa
3199 next unless $rellsid;
3200 next unless $relationships_found{$rellsid}; # e.g. $rels{urn:lsid...isa}=["urn:lsid...:Object","urn:lsid...:VirtSeq"]
3201 my @lsids_articles = @{$relationships_found{$rellsid}};
3202 next unless scalar @lsids_articles;
3203  
3204 $response .= "<Relationship relationshipType='$this_rel' lsid='$rellsid'>\n";
3205 foreach my $lsid_article ( @lsids_articles ) {
3206 my $lsid = $lsid_article->{lsid};
3207 my $term = $lsid_article->{term};
3208 if ($this_rel =~ /isa/i){
3209 $response .= "<${ontology}Type lsid='$lsid' ";
3210 $response .= ">$term</${ontology}Type>\n";
3211 } else {
3212 my @articleNames = keys %{$lsid_article->{'articleName'}};
3213 foreach my $articleName(@articleNames){
3214 $response .= "<${ontology}Type lsid='$lsid' ";
3215 $response .= "articleName='$articleName'" if $articleName; # wont be there for Service type ontology
3216 $response .= ">$term</${ontology}Type>\n";
3217 }
3218 }
3219 }
3220 $response .= "</Relationship>\n";
3221 }
3222  
3223 $response .= "</Relationships>\n";
3224 return $response;
3225 }
3226  
3227 =head2 DUMP_MySQL
3228  
3229 Title : DUMP_MySQL
3230 Usage : $SQL = $MOBY->DUMP_MySQL; ($central,$object,$service,$namespace,$relat) = @{$SQL};
3231 Function : return a mysql dump of each of the current MOBY Central databases
3232 Returns : an array of SQL strings that can be used to recreate the database locally
3233 Args : none
3234  
3235 =cut
3236  
3237 sub DUMP_MySQL {
3238 my ($pkg) = @_;
3239 my $config = MOBY::Config->new();
3240 my @dbsections = (
3241 'mobycentral', 'mobyobject',
3242 'mobyservice', 'mobynamespace',
3243 'mobyrelationship'
3244 );
3245 my @response;
3246 foreach my $dbsection (@dbsections) {
3247 my $dbname = ${ ${$config}{$dbsection} }{'dbname'};
3248 my $username = ${ ${$config}{$dbsection} }{'username'};
3249 my $password = ${ ${$config}{$dbsection} }{'password'};
3250 my $host = ${ ${$config}{$dbsection} }{'url'};
3251 my $port = ${ ${$config}{$dbsection} }{'port'};
3252 open( IN,
3253 "mysqldump -h $host -P $port -u $username --password=$password $dbname|"
3254 )
3255 || die "can't open $dbname for dumping";
3256 my @dbdump;
3257 while (<IN>) {
3258 push @dbdump, $_;
3259 }
3260 my $dbdump = ( join "", @dbdump );
3261 push @response, $dbdump;
3262 }
3263 return [@response];
3264 }
3265 *DUMP = \&DUMP_MySQL; # alias it for backward compatibility
3266  
3267 #sub _flatten {
3268 # $CONFIG ||= MOBY::Config->new; # exported by Config.pm
3269 # my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
3270 #
3271 # # from a given term, traverse the ontology
3272 # # and flatten it into a list of parent terms
3273 # my ( $dbh, $type, $term, $seen ) = @_;
3274 #
3275 # my $result = $adaptor->get_parent_terms(relationship_type_id => $type,
3276 # term => $term);
3277 #
3278 # foreach my $row (@$result) {
3279 # my $term = $row->{term};
3280 # next if ${$seen}{$term};
3281 # &_flatten( $dbh, $type, $term, $seen );
3282 # ${$seen}{$term} = 1;
3283 # }
3284 #}
3285  
3286 #Eddie - Converted
3287 sub _ISAPayload {
3288 my ($payload) = @_;
3289 my $Parser = XML::LibXML->new();
3290 my $doc = $Parser->parse_string($payload);
3291 my $Object = $doc->getDocumentElement();
3292 my $obj = $Object->nodeName;
3293 return undef unless ( $obj eq 'ISA' );
3294 my $type = &_nodeTextContent( $Object, "objectType" );
3295 return ($type);
3296 }
3297 =cut
3298  
3299  
3300  
3301  
3302  
3303  
3304  
3305  
3306 =head1 Internal Object Methods
3307  
3308  
3309 =cut
3310  
3311 =head2 _getValidServices
3312  
3313 Title : _getValidServices
3314 Usage : %valid = $MOBY->_getValidServices($sth_hash, $query, $max_return)
3315 Function : execute the query in $query to return a non-redundant list of matching services
3316 Returns : XML
3317 Args : none
3318  
3319 =cut
3320  
3321 #sub _getValidServices {
3322 # my ($sth_hash, $query, $max_return ) = @_;
3323 # my %sth = %{$sth_hash};
3324 # $debug && &_LOG("QUERY: \n$query\n\n");
3325 # my $this_query = $dbh->prepare($query);
3326 # $this_query->execute;
3327 # my $response;
3328 # my %seen;
3329 # $response = "<Services>\n";
3330 #
3331 # while ( my ( $serviceName, $objectOUT, $AuthURI, $desc, $type, $cat ) =
3332 # $this_query->fetchrow_array() )
3333 # {
3334 # $debug
3335 # && &_LOG("$serviceName, $objectOUT, $AuthURI,$desc, $type, $cat\n");
3336 # next
3337 # if $seen{ "$AuthURI" . "||"
3338 # . "$serviceName" }; # non-redundant list please
3339 # $seen{ "$AuthURI" . "||" . "$serviceName" } = 1;
3340 # $response .=
3341 # "<Service authURI='$AuthURI' serviceName='$serviceName'>\n";
3342 # $response .= "<Category>$cat</Category>\n";
3343 # $response .= "<serviceType>$type</serviceType>\n";
3344 # $response .= "<outputObject>$objectOUT</outputObject>\n";
3345 # if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
3346 # $desc = $1;
3347 # }
3348 # $response .= "<Description><![CDATA[$desc]]></Description>\n";
3349 # $response .= "</Service>\n";
3350 # if ($max_return) { --$max_return; last unless $max_return }
3351 # }
3352 # $response .= "</Services>\n";
3353 # $debug && &_LOG("\nFINAL RESPONSE IS \n$response\n\n");
3354 # return $response;
3355 #}
3356  
3357 =head2 _getServiceWSDL
3358  
3359 Title : _getServiceWSDL
3360 Usage : @valid = $MOBY->_getValidServices($dbh, $sth_hash, $query)
3361 Function : execute the query in $query to return a non-redundant list of matching services
3362 Returns : list of response strings in wsdl
3363 Args : none
3364  
3365 =cut
3366  
3367 sub _getServiceWSDL {
3368 my ( $SI, $InputXML, $OutputXML, $SecondaryXML ) = @_;
3369  
3370 # the lines below causes no end of grief. It is now in a variable.
3371 #open (WSDL, "./MOBY/Central_WSDL_SandR.wsdl") || die "can't open WSDL file for search and replace\n";
3372 #my $wsdl = join "", (<WSDL>);
3373  
3374 #close WSDL;
3375 # do substitutions
3376 my $serviceType = $SI->category;
3377 my $wsdl;
3378 if ($serviceType eq "cgi"){
3379 $wsdl = &_doPostWSDLReplacement(@_)
3380 } elsif ($serviceType eq "moby"){
3381 $wsdl = &_doMobyWSDLReplacement(@_)
3382 } elsif ($serviceType eq "moby-async"){
3383 $wsdl = &_doAsyncWSDLReplacement(@_)
3384 } elsif ($serviceType eq "cgi-async"){
3385 $wsdl = &_doAsyncPostWSDLReplacement(@_)
3386 }
3387 return $wsdl;
3388 }
3389  
3390 sub _doAsyncWSDLReplacement {
3391 # this routine does not work at the moment
3392 # we're just waiting for an example of an async
3393 # wsdl document from IMB
3394 my ( $SI, $InputXML, $OutputXML, $SecondaryXML ) = @_;
3395 my $wsdl = $WSDL_ASYNC_TEMPLATE;
3396 $wsdl =~ s/^\n//gs;
3397 my $serviceName = $SI->servicename;
3398 my $AuthURI = $SI->authority_uri;
3399 my $desc = $SI->description;
3400 if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
3401 $desc = $1;
3402 }
3403 $desc =~ s"\<"&lt;"g; # XMl encode now that it is not CDATAd
3404 $desc =~ s"\>"&gt;"g; # XML encode now that it is not CDATAd
3405 my $URL = $SI->url;
3406 my $IN = "NOT_YET_DEFINED_INPUTS";
3407 my $OUT = "NOT_YET_DEFINED_OUTPUTS";
3408 my $INxsd = &_getInputXSD( $InputXML, $SecondaryXML );
3409 my $OUTxsd = &_getOutputXSD($OutputXML);
3410 $INxsd ||= "<NOT_YET_IMPLEMENTED_INPUT_XSD/>";
3411 $OUTxsd ||= "<NOT_YET_IMPLEMENTED_OUTPUT_XSD/>";
3412 $wsdl =~ s/MOBY__SERVICE__NAME__/$serviceName/g; # replace all of the goofy portbindingpottype crap
3413 $wsdl =~s/\<\!\-\-\s*MOBY__SERVICE__DESCRIPTION\s*\-\-\>/Authority: $AuthURI - $desc/g; # add a sensible description
3414 $wsdl =~ s/MOBY__SERVICE__URL/$URL/g; # the URL to the service
3415 $wsdl =~ s/MOBY__SERVICE__NAME/$serviceName/g; # finally replace the actual subroutine call
3416 return $wsdl;
3417 }
3418  
3419 sub _doAsyncPostWSDLReplacement {
3420 my ( $SI, $InputXML, $OutputXML, $SecondaryXML ) = @_;
3421 my $wsdl = $WSDL_ASYNC_POST_TEMPLATE;
3422 $wsdl =~ s/^\n//gs;
3423 my $serviceName = $SI->servicename;
3424 my $AuthURI = $SI->authority_uri;
3425 my $desc = $SI->description;
3426 if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
3427 $desc = $1;
3428 }
3429 $desc =~ s"\<"&lt;"g; # XMl encode now that it is not CDATAd
3430 $desc =~ s"\>"&gt;"g; # XML encode now that it is not CDATAd
3431 my $URL = $SI->url;
3432 $URL =~ "(http://[^/]+)(/.*)";
3433 my $baseURL = $1;
3434 my $relativeURL = $2;
3435 my $IN = "NOT_YET_DEFINED_INPUTS";
3436 my $OUT = "NOT_YET_DEFINED_OUTPUTS";
3437 my $INxsd = &_getInputXSD( $InputXML, $SecondaryXML );
3438 my $OUTxsd = &_getOutputXSD($OutputXML);
3439 $INxsd ||= "<NOT_YET_IMPLEMENTED_INPUT_XSD/>";
3440 $OUTxsd ||= "<NOT_YET_IMPLEMENTED_OUTPUT_XSD/>";
3441 $wsdl =~ s/MOBY__SERVICE__NAME__/$serviceName/g; # replace all of the goofy portbindingpottype crap
3442 $wsdl =~s/\<\!\-\-\s*MOBY__SERVICE__DESCRIPTION\s*\-\-\>/Authority: $AuthURI - $desc/g; # add a sensible description
3443 $wsdl =~ s/MOBY__SERVICE__URL/$baseURL/g; # the URL to the service
3444 $wsdl =~ s/MOBY__SERVICE__POST/$relativeURL/g; # the URL to the service
3445 $wsdl =~ s/MOBY__SERVICE__NAME/$serviceName/g; # finally replace the actual subroutine call
3446 return $wsdl;
3447 }
3448  
3449 sub _doPostWSDLReplacement {
3450 my ( $SI, $InputXML, $OutputXML, $SecondaryXML ) = @_;
3451 my $wsdl = $WSDL_POST_TEMPLATE;
3452 $wsdl =~ s/^\n//gs;
3453 my $serviceName = $SI->servicename;
3454 my $AuthURI = $SI->authority_uri;
3455 my $desc = $SI->description;
3456 if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
3457 $desc = $1;
3458 }
3459 $desc =~ s"\<"&lt;"g; # XMl encode now that it is not CDATAd
3460 $desc =~ s"\>"&gt;"g; # XML encode now that it is not CDATAd
3461 my $URL = $SI->url;
3462 $URL =~ "(http://[^/]+)(/.*)";
3463 my $baseURL = $1;
3464 my $relativeURL = $2;
3465 my $IN = "NOT_YET_DEFINED_INPUTS";
3466 my $OUT = "NOT_YET_DEFINED_OUTPUTS";
3467 my $INxsd = &_getInputXSD( $InputXML, $SecondaryXML );
3468 my $OUTxsd = &_getOutputXSD($OutputXML);
3469 $INxsd ||= "<NOT_YET_IMPLEMENTED_INPUT_XSD/>";
3470 $OUTxsd ||= "<NOT_YET_IMPLEMENTED_OUTPUT_XSD/>";
3471 $wsdl =~ s/MOBY__SERVICE__NAME__/$serviceName/g; # replace all of the goofy portbindingpottype crap
3472 $wsdl =~s/\<\!\-\-\s*MOBY__SERVICE__DESCRIPTION\s*\-\-\>/Authority: $AuthURI - $desc/g; # add a sensible description
3473 $wsdl =~ s/MOBY__SERVICE__URL/$baseURL/g; # the URL to the service
3474 $wsdl =~ s/MOBY__SERVICE__POST/$relativeURL/g; # the URL to the service
3475 $wsdl =~ s/MOBY__SERVICE__NAME/$serviceName/g; # finally replace the actual subroutine call
3476 return $wsdl;
3477 }
3478  
3479  
3480 sub _doMobyWSDLReplacement {
3481 my ( $SI, $InputXML, $OutputXML, $SecondaryXML ) = @_;
3482 my $wsdl = $WSDL_TEMPLATE;
3483 $wsdl =~ s/^\n//gs;
3484 my $serviceName = $SI->servicename;
3485 my $AuthURI = $SI->authority_uri;
3486 my $desc = $SI->description;
3487 if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
3488 $desc = $1;
3489 }
3490 $desc =~ s"\<"&lt;"g; # XMl encode now that it is not CDATAd
3491 $desc =~ s"\>"&gt;"g; # XML encode now that it is not CDATAd
3492 my $URL = $SI->url;
3493 my $IN = "NOT_YET_DEFINED_INPUTS";
3494 my $OUT = "NOT_YET_DEFINED_OUTPUTS";
3495 my $INxsd = &_getInputXSD( $InputXML, $SecondaryXML );
3496 my $OUTxsd = &_getOutputXSD($OutputXML);
3497 $INxsd ||= "<NOT_YET_IMPLEMENTED_INPUT_XSD/>";
3498 $OUTxsd ||= "<NOT_YET_IMPLEMENTED_OUTPUT_XSD/>";
3499 $wsdl =~ s/MOBY__SERVICE__NAME__/$serviceName/g; # replace all of the goofy portbindingpottype crap
3500 $wsdl =~s/\<\!\-\-\s*MOBY__SERVICE__DESCRIPTION\s*\-\-\>/Authority: $AuthURI - $desc/g; # add a sensible description
3501 $wsdl =~ s/MOBY__SERVICE__URL/$URL/g; # the URL to the service
3502 $wsdl =~ s/MOBY__SERVICE__NAME/$serviceName/g; # finally replace the actual subroutine call
3503 return $wsdl
3504 }
3505  
3506  
3507 #sub _getCGIService {
3508 # my ( $dbh, $sth_hash, $id, $serviceName, $AuthURI, $URL, $desc, $category )
3509 # = @_;
3510 # my %sth = %{$sth_hash};
3511 #
3512 # # "Select OE.term, O.xsd, SP.type
3513 # # from Object as O, OntologyEntry as OE, ServiceParameter as SP, Service as S
3514 # # where O.ontologyentry_id = OE.id
3515 # # AND SP.ontologyentry_id = OE.id
3516 # # and SP.service_id = ?
3517 # my $sth = $dbh->prepare( $sth{get_server_parameters} );
3518 # $sth->execute($id);
3519 # my ( $Object, $sprintf, $in ) = $sth->fetchrow_array();
3520 # if ( $sprintf =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
3521 # $sprintf = $1;
3522 # }
3523 # return "<GETstring><![CDATA[$sprintf]]></GETstring>";
3524 #}
3525  
3526  
3527 #Eddie - converted
3528 sub _nodeTextContent {
3529  
3530 # will get text of **all** child $node from the given $DOM
3531 # regardless of their depth!!
3532 my ( $DOM, $node ) = @_;
3533 $debug && &_LOG( "_nodeTextContent received DOM: ",
3534 $DOM->toString, "\nsearching for node $node\n" );
3535 my $x = $DOM->getElementsByTagName($node);
3536 return undef unless $x->get_node(1);
3537 my @child = $x->get_node(1)->childNodes;
3538 my $content;
3539 foreach (@child) {
3540 $debug
3541 && &_LOG( $_->nodeType, "\t", $_->toString, "\n" );
3542  
3543 #next unless $_->nodeType == TEXT_NODE;
3544 $content .= $_->textContent;
3545 }
3546 return $content;
3547 }
3548  
3549 sub _nodeCDATAContent {
3550  
3551 # will get text of **all** child $node from the given $DOM
3552 # regardless of their depth!!
3553 my ( $DOM, $node ) = @_;
3554 $debug && &_LOG( "_nodeTextContent received DOM: ",
3555 $DOM->toString, "\nsearching for node $node\n" );
3556 my $x = $DOM->getElementsByTagName($node);
3557 return undef unless $x->get_node(1);
3558 my @child = $x->get_node(1)->childNodes;
3559 my $content;
3560 foreach (@child) {
3561 $debug
3562 && &_LOG( $_->nodeType, "\t", $_->toString, "\n" );
3563  
3564 #next unless $_->nodeType == TEXT_NODE;
3565 if ( $_->toString =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
3566 $content .= $1;
3567 }
3568 else {
3569 $content .= $_->textContent;
3570 }
3571 }
3572 return $content;
3573 }
3574  
3575 #Eddie - converted
3576 sub _nodeRawContent {
3577  
3578 # will get raw child nodes of $node from the given $DOM
3579 my ( $DOM, $nodename ) = @_;
3580 my @content;
3581 $debug && &_LOG( "_nodeRawContent received DOM: ",
3582 $DOM->toString, "\nsearching for node $nodename\n" );
3583 my $x = $DOM->getElementsByTagName($nodename);
3584 my $node = $x->get_node(1);
3585 return [] unless $node;
3586 foreach my $child ( $node->childNodes ) {
3587 next unless $child->nodeType == ELEMENT_NODE;
3588 push @content, $child;
3589 }
3590 return \@content;
3591 }
3592  
3593 #Eddie - converted
3594 sub _nodeArrayContent {
3595  
3596 # will get array content of all child $node from given $DOM
3597 # regardless of depth!
3598 # e.g. the following XML:
3599 #<ISA>
3600 # <objectType>first</objectType>
3601 # <objectType>second</objectType>
3602 #</ISA>
3603 #will return the list "first", "second"
3604 my ( $DOM, $node ) = @_;
3605 $debug && &_LOG( "_nodeArrayContext received DOM: ",
3606 $DOM->toString, "\nsearching for node $node\n" );
3607 my @result;
3608 my $x = $DOM->getElementsByTagName($node);
3609 return @result unless $x->get_node(1);
3610 my @child = $x->get_node(1)->childNodes;
3611 foreach (@child) {
3612 next unless $_->nodeType == ELEMENT_NODE;
3613 my @child2 = $_->childNodes;
3614 foreach (@child2) {
3615  
3616 #print getNodeTypeName($_), "\t", $_->toString,"\n";
3617 next unless $_->nodeType == TEXT_NODE;
3618 next unless ( length( $_->toString ) > 0 );
3619 push @result, $_->toString;
3620 }
3621 }
3622 $debug && _LOG("_nodeArrayContent resulted in @result\n");
3623 return @result;
3624 }
3625  
3626 #Eddie - converted
3627 sub _nodeArrayExtraContent {
3628  
3629 # will get array content of all child $node from given $DOM
3630 # regardless of depth!
3631 # e.g. the following XML:
3632 #<ISA>
3633 # <objectType articleName="thisone">first</objectType>
3634 # <objectType articleName="otherone">second</objectType>
3635 #</ISA>
3636 #will return the list
3637 # ['first',{'articleName' => 'thisone'}],
3638 # ['second',{'articleName' => 'otherone'},...
3639 my ( $DOM, $node, @attrs ) = @_;
3640 $debug && &_LOG( "_nodeArrayExtraContext received DOM: ",
3641 $DOM->toString, "\nsearching for node $node\n" );
3642 my @result;
3643 my %att_value;
3644 my $x = $DOM->getElementsByTagName($node);
3645 my @child = $x->get_node(1)->childNodes;
3646 foreach (@child) {
3647 next unless $_->nodeType == ELEMENT_NODE;
3648 foreach my $attr (@attrs) {
3649 $debug && &_LOG( "_nodeArrayExtraContext received DOM: ",
3650 $DOM->toString, "\nsearching for attributre $attr\n" );
3651 my $article =
3652 $_->getAttributeNode($attr); # may or may not have a name
3653 if ($article) { $article = $article->getValue() }
3654 $att_value{$attr} = $article;
3655 }
3656 my @child2 = $_->childNodes;
3657 foreach (@child2) {
3658  
3659 #print getNodeTypeName($_), "\t", $_->toString,"\n";
3660 next unless $_->nodeType == TEXT_NODE;
3661 push @result, [ $_->toString, \%att_value ];
3662 }
3663 }
3664 $debug && &_LOG(@result);
3665 return @result;
3666 }
3667  
3668 sub _serviceListResponse {
3669
3670
3671 $CONFIG ||= MOBY::Config->new; # exported by Config.pm
3672 my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
3673  
3674 my (@ids ) = @_;
3675 my $output = "";
3676 my $OSobj = MOBY::OntologyServer->new( ontology => 'object' );
3677 my $OSns = MOBY::OntologyServer->new( ontology => 'namespace' );
3678 my $OSserv = MOBY::OntologyServer->new( ontology => 'service' );
3679  
3680 my $root = new XML::LibXML::Element("Services");
3681
3682 foreach (@ids) {
3683 my $result = $adaptor->query_service_instance(service_instance_id => $_);
3684 my $row = shift(@$result);
3685 my $category = $row->{category};
3686 my $url = $row->{url};
3687 my $servicename = $row->{servicename};
3688 my $service_type_uri = $row->{service_type_uri};
3689 my $authority_uri = $row->{authority_uri};
3690 my $desc = $row->{description};
3691 my $authoritative = $row->{authoritative};
3692 my $email = $row->{contact_email};
3693 my $signatureURL = $row->{signatureURL};
3694 my $lsid = $row->{lsid};
3695
3696 if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
3697 $desc = $1;
3698 }
3699  
3700 $signatureURL ||= "";
3701 next unless ( $servicename && $authority_uri );
3702 my $service_type = $OSserv->getServiceCommonName($service_type_uri);
3703  
3704 my $serviceNode = new XML::LibXML::Element("Service");
3705 $serviceNode->setAttribute("authURI",$authority_uri);
3706 $serviceNode->setAttribute("serviceName",$servicename);
3707 $serviceNode->setAttribute("lsid",$lsid);
3708
3709 my $subElement = new XML::LibXML::Element("serviceType");
3710 $subElement->setAttribute("lsid",$service_type_uri);
3711 $subElement->appendText($service_type);
3712 $serviceNode->appendChild($subElement);
3713
3714 $subElement = new XML::LibXML::Element("authoritative");
3715 $subElement->appendText($authoritative);
3716 $serviceNode->appendChild($subElement);
3717
3718 $subElement = new XML::LibXML::Element("Category");
3719 $subElement->appendText($category);
3720 $serviceNode->appendChild($subElement);
3721
3722 $subElement = new XML::LibXML::Element("Description");
3723 $subElement->appendChild(XML::LibXML::CDATASection->new($desc));
3724 $serviceNode->appendChild($subElement);
3725
3726 $subElement = new XML::LibXML::Element("contactEmail");
3727 $subElement->appendText($email);
3728 $serviceNode->appendChild($subElement);
3729
3730 $subElement = new XML::LibXML::Element("signatureURL");
3731 $subElement->appendText($signatureURL);
3732 $serviceNode->appendChild($subElement);
3733
3734 $subElement = new XML::LibXML::Element("URL");
3735 $subElement->appendText($url);
3736 $serviceNode->appendChild($subElement);
3737
3738 $subElement = new XML::LibXML::Element("Input");
3739
3740
3741 #$output .= "\t<Service authURI='$authority_uri' serviceName='$servicename' lsid='$lsid'>\n";
3742 #$output .= "\t<serviceType lsid='$service_type_uri'>$service_type</serviceType>\n";
3743 #$output .= "\t<authoritative>$authoritative</authoritative>\n";
3744 #$output .= "\t<Category>$category</Category>\n";
3745 #$output .= "\t<Description><![CDATA[$desc]]></Description>\n";
3746 #$output .= "\t<contactEmail>$email</contactEmail>\n";
3747 #$output .= "\t<signatureURL>$signatureURL</signatureURL>\n";
3748 #$output .= "\t<URL>$url</URL>\n";
3749 #$output .= "\t<Input>\n";
3750  
3751 $result = $adaptor->query_simple_input(service_instance_lsid => $lsid);
3752
3753 foreach my $row (@$result)
3754 {
3755 my $objURI = $row->{object_type_uri};
3756 my $nsURI = $row->{namespace_type_uris};
3757 my $article = $row->{article_name};
3758  
3759 my $objName = $OSobj->getObjectCommonName($objURI);
3760 $nsURI ||= "";
3761 my @nsURIs = split ",", $nsURI;
3762 $article ||= "";
3763
3764 my $simpleElement = new XML::LibXML::Element("Simple");
3765 $simpleElement->setAttribute("articleName",$article);
3766 my $typeElement = new XML::LibXML::Element("objectType");
3767 $typeElement->setAttribute("lsid", $objURI);
3768 $typeElement->appendText($objName);
3769 $simpleElement->appendChild($typeElement);
3770
3771
3772 #$output .= "\t\t<Simple articleName='$article'>\n";
3773 #$output .= "\t\t\t<objectType lsid='$objURI'>$objName</objectType>\n";
3774 foreach my $ns (@nsURIs) {
3775 my $NSname = $OSns->getNamespaceCommonName($ns);
3776 #$output .= "\t\t\t<Namespace lsid='$ns'>$NSname</Namespace>\n" if $NSname;
3777 my $nsElement = new XML::LibXML::Element("Namespace");
3778 $nsElement->setAttribute("lsid", $ns) if $NSname;
3779 $nsElement->appendText($NSname) if $NSname;
3780 $simpleElement->appendChild($nsElement) if $NSname;
3781 }
3782 #$output .= "\t\t</Simple>\n";
3783 $subElement->appendChild($simpleElement);
3784 }
3785 $result = $adaptor->query_collection_input(service_instance_lsid => $lsid);
3786  
3787 foreach my $row (@$result)
3788 {
3789 my $collid = $row->{collection_input_id};
3790 my $articlename = $row->{article_name};
3791  
3792 #$output .= "\t\t<Collection articleName='$articlename'>\n";
3793 my $collectionElement = new XML::LibXML::Element("Collection");
3794 $collectionElement->setAttribute("articleName",$articlename);
3795
3796 my $result2 = $adaptor->query_simple_input(service_instance_lsid => undef, collection_input_id => $collid);
3797 foreach my $row2 (@$result2)
3798 {
3799 my $objURI = $row2->{object_type_uri};
3800 my $nsURI = $row2->{namespace_type_uris};
3801 my $article = $row2->{article_name};
3802  
3803 my $objName = $OSobj->getObjectCommonName($objURI);
3804 $nsURI ||= "";
3805 my @nsURIs = split ",", $nsURI;
3806 $article ||= "";
3807
3808 #$output .= "\t\t\t<Simple articleName='$article'>\n";
3809 #$output .= "\t\t\t\t<objectType lsid='$objURI'>$objName</objectType>\n";
3810
3811 my $simpleElement = new XML::LibXML::Element("Simple");
3812 $simpleElement->setAttribute("articleName",$article);
3813 my $typeElement = new XML::LibXML::Element("objectType");
3814 $typeElement->setAttribute("lsid", $objURI);
3815 $typeElement->appendText($objName);
3816 $simpleElement->appendChild($typeElement);
3817
3818 foreach my $ns (@nsURIs) {
3819 my $NSname = $OSns->getNamespaceCommonName($ns);
3820 #$output .= "\t\t\t\t<Namespace lsid='$ns'>$NSname</Namespace>\n" if $NSname;
3821 my $nsElement = new XML::LibXML::Element("Namespace");
3822 $nsElement->setAttribute("lsid", $ns) if $NSname;
3823 $nsElement->appendText($NSname) if $NSname;
3824 $simpleElement->appendChild($nsElement) if $NSname;
3825 }
3826 #$output .= "\t\t\t</Simple>\n";
3827 $collectionElement->appendChild($simpleElement);
3828 }
3829 $subElement->appendChild($collectionElement);
3830 #$output .= "\t\t</Collection>\n";
3831 }
3832 #$output .= "\t</Input>\n";
3833 $serviceNode->appendChild($subElement);
3834 #$output .= "\t<Output>\n";
3835
3836 $subElement = new XML::LibXML::Element("Output");
3837
3838 $result = $adaptor->query_simple_output(service_instance_lsid => $lsid, collection_output_id => undef);
3839
3840 foreach my $row (@$result)
3841 {
3842 my $objURI = $row->{object_type_uri};
3843 my $nsURI = $row->{namespace_type_uris};
3844 my $article = $row->{article_name};
3845  
3846 my $objName = $OSobj->getObjectCommonName($objURI);
3847 $nsURI ||= "";
3848 my @nsURIs = split ",", $nsURI;
3849 $article ||= "";
3850 my $simpleElement = new XML::LibXML::Element("Simple");
3851 $simpleElement->setAttribute("articleName",$article);
3852 my $typeElement = new XML::LibXML::Element("objectType");
3853 $typeElement->setAttribute("lsid", $objURI);
3854 $typeElement->appendText($objName);
3855 $simpleElement->appendChild($typeElement);
3856
3857 #$output .= "\t\t<Simple articleName='$article'>\n";
3858 #$output .= "\t\t\t<objectType lsid='$objURI'>$objName</objectType>\n";
3859 foreach my $ns (@nsURIs) {
3860 my $NSname = $OSns->getNamespaceCommonName($ns);
3861 #$output .= "\t\t\t<Namespace lsid='$ns'>$NSname</Namespace>\n" if $NSname;
3862 my $nsElement = new XML::LibXML::Element("Namespace");
3863 $nsElement->setAttribute("lsid", $ns) if $NSname;
3864 $nsElement->appendText($NSname) if $NSname;
3865 $simpleElement->appendChild($nsElement) if $NSname;
3866 }
3867 #$output .= "\t\t</Simple>\n";
3868 $subElement->appendChild($simpleElement);
3869 }
3870  
3871 $result = $adaptor->query_collection_output(service_instance_lsid => $lsid);
3872 foreach my $row (@$result)
3873 {
3874 my $collid = $row->{collection_output_id};
3875 my $articlename = $row->{article_name};
3876 #$output .= "\t\t<Collection articleName='$articlename'>\n";
3877
3878 my $collectionElement = new XML::LibXML::Element("Collection");
3879 $collectionElement->setAttribute("articleName",$articlename);
3880
3881 my $result2 = $adaptor->query_simple_output(service_instance_lsid => undef, collection_output_id => $collid);
3882 foreach my $row2 (@$result2 )
3883 {
3884 my $objURI = $row2->{object_type_uri};
3885 my $nsURI = $row2->{namespace_type_uris};
3886 my $article = $row2->{article_name};
3887 my $objName = $OSobj->getObjectCommonName($objURI);
3888 $nsURI ||= "";
3889 my @nsURIs = split ",", $nsURI;
3890 $article ||= "";
3891 #$output .= "\t\t\t<Simple articleName='$article'>\n";
3892 #$output .= "\t\t\t\t<objectType lsid='$objURI'>$objName</objectType>\n";
3893
3894 my $simpleElement = new XML::LibXML::Element("Simple");
3895 $simpleElement->setAttribute("articleName",$article);
3896 my $typeElement = new XML::LibXML::Element("objectType");
3897 $typeElement->setAttribute("lsid", $objURI);
3898 $typeElement->appendText($objName);
3899 $simpleElement->appendChild($typeElement);
3900
3901 foreach my $ns (@nsURIs) {
3902 my $NSname = $OSns->getNamespaceCommonName($ns);
3903 #$output .= "\t\t\t\t<Namespace lsid='$ns'>$NSname</Namespace>\n" if $NSname;
3904 my $nsElement = new XML::LibXML::Element("Namespace");
3905 $nsElement->setAttribute("lsid", $ns) if $NSname;
3906 $nsElement->appendText($NSname) if $NSname;
3907 $simpleElement->appendChild($nsElement) if $NSname;
3908 }
3909 #$output .= "\t\t\t</Simple>\n";
3910 $collectionElement->appendChild($simpleElement);
3911 }
3912 #$output .= "\t\t</Collection>\n";
3913 $subElement->appendChild($collectionElement);
3914 }
3915 #$output .= "\t</Output>\n";
3916 $serviceNode->appendChild($subElement);
3917
3918
3919 #$output .= "\t<secondaryArticles>\n";
3920 $subElement = new XML::LibXML::Element("secondaryArticles");
3921 $result = $adaptor->query_secondary_input(service_instance_lsid => $lsid);
3922 foreach my $row (@$result)
3923 { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $description,$article_name) = ("","","","","","");
3924 $default_value = $row->{default_value};
3925 $maximum_value = $row->{maximum_value};
3926 $minimum_value = $row->{minimum_value};
3927 $enum_value = $row->{enum_value};
3928 $datatype = $row->{datatype};
3929 $description = $row->{description};
3930 $article_name = $row->{article_name};
3931
3932 my $parElement = new XML::LibXML::Element("Parameter");
3933 $parElement->setAttribute("articleName",$article_name);
3934 $parElement->appendTextChild( "datatype" , $datatype);
3935 # TODO should this description be wrapped in CDATA??
3936 $parElement->appendTextChild( "description" , $description);
3937 $parElement->appendTextChild( "default" , $default_value);
3938 $parElement->appendTextChild( "max" , $maximum_value);
3939 $parElement->appendTextChild( "min" , $minimum_value);
3940
3941 #$output .= "\t\t\t<Parameter articleName='$article_name'>\n";
3942 #$output .= "\t\t\t\t<datatype>$datatype</datatype>\n";
3943 #$output .= "\t\t\t\t<description>$description</description>\n";
3944 #$output .= "\t\t\t\t<default>$default_value</default>\n";
3945 #$output .= "\t\t\t\t<max>$maximum_value</max>\n";
3946 #$output .= "\t\t\t\t<min>$minimum_value</min>\n";
3947
3948 my @enums = split ",", $enum_value;
3949  
3950 if ( scalar(@enums) ) {
3951 foreach my $enum (@enums) {
3952 #$output .= "\t\t\t\t<enum>$enum</enum>\n";
3953 $parElement->appendTextChild( "enum" , $enum);
3954 }
3955 }
3956 else {
3957 #$output .= "\t\t\t\t<enum></enum>\n";
3958 $parElement->appendChild( new XML::LibXML::Element("enum") );
3959 }
3960 #$output .= "\t\t\t</Parameter>\n";
3961 $subElement->appendChild($parElement);
3962 }
3963
3964 #$output .= "\t\t</secondaryArticles>\n";
3965 $serviceNode->appendChild($subElement);
3966 #$output .= "\t</Service>\n";
3967 $root->appendChild($serviceNode);
3968 }
3969 return $root->toString(1);
3970 #return "<Services>\n$output\n</Services>\n";
3971 }
3972  
3973 sub _error {
3974 my ( $message, $id ) = @_;
3975 $id ||="";
3976 $message ||="";
3977
3978 my $reg = &Registration(
3979 {
3980 success => 0,
3981 message => "$message",
3982 id => "$id",
3983 }
3984 );
3985 return $reg;
3986 }
3987  
3988 sub _success {
3989 my ( $message, $id, $RDF ) = @_;
3990 my $reg = &Registration(
3991 {
3992 success => 1,
3993 message => "$message",
3994 id => "$id",
3995 RDF => $RDF,
3996 }
3997 );
3998 return $reg;
3999 }
4000  
4001 sub _getOntologyServer { # may want to make this more complex
4002 my (%args) = @_;
4003 my $OS = MOBY::OntologyServer->new(%args);
4004 return $OS;
4005 }
4006 sub DESTROY { }
4007  
4008 sub _LOG {
4009  
4010 return unless $debug;
4011 #print join "\n", @_;
4012 #print "\n---\n";
4013 #return;
4014 open LOG, ">>/tmp/CentralRegistryLogOut.txt"
4015 or die "can't open mobycentral error logfile $!\n";
4016 print LOG join "\n", @_;
4017 print LOG "\n---\n";
4018 close LOG;
4019 }
4020  
4021 #
4022 #
4023 # --------------------------------------------------------------------------------------------------------
4024 #
4025 ##
4026 ##
4027  
4028 =head2 _getInputXSD
4029  
4030 name : _getInputXSD($InputXML, $SecondaryXML)
4031 function: to get an XSD describing the input to a MOBY Service,
4032 e.g. to use in a WSDL document
4033 args : (see _serviceListResponse code above for full details of XML)
4034 $InputXML - the <Input>...</Input> block of a findService
4035 response message
4036  
4037 $SecondaryXML - the <secondaryArticles>...<sescondaryArticles>
4038 fragment of a findService response message
4039  
4040 returns : XSD fragment of XML (should not return an XML header!)
4041 notes : the structure of an Input block is as follows:
4042 <Input>
4043 <!-- one or more Simple or Collection articles -->
4044 </Input>
4045  
4046 the structure of a secondaryArticle block is as follows:
4047 <sescondaryArticles>
4048 <!-- one or more Parameter blocks -->
4049 </secondaryArticles>
4050  
4051  
4052 =over
4053  
4054 =item * Simple
4055  
4056 <Simple articleName="NameOfArticle">
4057 <objectType>ObjectOntologyTerm</objectType>
4058 <Namespace>NamespaceTerm</Namespace>
4059 <Namespace>...</Namespace><!-- one or more... -->
4060 </Simple>
4061  
4062 =item * Collection note that articleName of the contained Simple objects is not required, and is ignored.
4063  
4064  
4065 <Collection articleName="NameOfArticle">
4066 <Simple>......</Simple> <!-- Simple parameter type structure -->
4067 <Simple>......</Simple> <!-- DIFFERENT Simple parameter type
4068 (used only when multiple Object Classes
4069 appear in a collection) -->
4070 </Collection>
4071  
4072 =item * Secondary
4073  
4074  
4075 <Parameter articleName="NameOfArticle">
4076 <datatype>INT|FLOAT|STRING</datatype>
4077 <default>...</default> <!-- any/all of these -->
4078 <max>...</max> <!-- ... -->
4079 <min>...</min> <!-- ... -->
4080 <enum>...<enum> <!-- ... -->
4081 <enum>...<enum> <!-- ... -->
4082 </Parameter>
4083  
4084 =back
4085  
4086 =cut
4087  
4088 sub _getInputXSD {
4089 my ( $Input, $Secondary ) = @_;
4090 my $XSD;
4091 return $XSD;
4092 }
4093  
4094 =head2 _getOuputXSD
4095  
4096 name : _getOutputXSD($OutputXML)
4097 function: to get an XSD describing the output from a MOBY Service
4098 e.g. to use in a WSDL document
4099 args : (see _serviceListResponse code above for full details)
4100 $InputXML - the <Input>...</Input> block of a findService
4101 response message
4102  
4103 $SecondaryXML - the <secondaryArticles>...<sescondaryArticles>
4104 fragment of a findService response message
4105  
4106 returns : XSD fragment of XML (should not return an XML header!)
4107 notes : the structure of an Output block is as follows:
4108 <Input>
4109 <!-- one or more Simple or Collection articles -->
4110 </Input>
4111  
4112 =over
4113  
4114 =item * Simple
4115  
4116 <Simple articleName="NameOfArticle">
4117 <objectType>ObjectOntologyTerm</objectType>
4118 <Namespace>NamespaceTerm</Namespace>
4119 <Namespace>...</Namespace><!-- one or more... -->
4120 </Simple>
4121  
4122 =item * Collection note that articleName of the contained Simple objects is not required, and is ignored.
4123  
4124  
4125 <Collection articleName="NameOfArticle">
4126 <Simple>......</Simple> <!-- Simple parameter type structure -->
4127 <Simple>......</Simple> <!-- DIFFERENT Simple parameter type
4128 (used only when multiple Object Classes
4129 appear in a collection) -->
4130 </Collection>
4131  
4132 =back
4133  
4134 =cut
4135  
4136 sub _getOutputXSD {
4137 my ($Output) = @_;
4138 my $XSD;
4139 return $XSD;
4140 }
4141  
4142  
4143  
4144 =head2 WSDL_Templates
4145  
4146 =cut
4147  
4148 #===============================================
4149 #===============================================
4150 #===============================================
4151  
4152 # Standard MOBY WSDL Template
4153  
4154  
4155 $WSDL_TEMPLATE = <<END;
4156 <?xml version="1.0"?>
4157 <wsdl:definitions name="MOBY_Central_Generated_WSDL"
4158 targetNamespace="http://biomoby.org/Central.wsdl"
4159 xmlns:tns="http://biomoby.org/Central.wsdl"
4160 xmlns:xsd1="http://biomoby.org/CentralXSDs.xsd"
4161 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4162 xmlns="http://schemas.xmlsoap.org/wsdl/"
4163 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
4164 xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/">
4165  
4166
4167 <wsdl:message name="MOBY__SERVICE__NAME__Input">
4168 <wsdl:part name="data" type="xsd:string"/>
4169 </wsdl:message>
4170  
4171 <wsdl:message name="MOBY__SERVICE__NAME__Output">
4172 <wsdl:part name="body" type="xsd:string"/>
4173 </wsdl:message>
4174  
4175 <wsdl:portType name="MOBY__SERVICE__NAME__PortType">
4176 <wsdl:operation name="MOBY__SERVICE__NAME">
4177 <wsdl:input message="tns:MOBY__SERVICE__NAME__Input"/>
4178 <wsdl:output message="tns:MOBY__SERVICE__NAME__Output"/>
4179 </wsdl:operation>
4180 </wsdl:portType>
4181
4182 <wsdl:binding name="MOBY__SERVICE__NAME__Binding" type="tns:MOBY__SERVICE__NAME__PortType">
4183 <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
4184 <wsdl:operation name="MOBY__SERVICE__NAME"><!-- in essense, this is the name of the subroutine that is called -->
4185 <wsdlsoap:operation soapAction='http://biomoby.org/#MOBY__SERVICE__NAME' style='rpc'/>
4186 <wsdl:input>
4187 <wsdlsoap:body use="encoded" namespace="http://biomoby.org/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
4188 </wsdl:input>
4189 <wsdl:output>
4190 <wsdlsoap:body use="encoded" namespace="http://biomoby.org/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
4191 </wsdl:output>
4192 </wsdl:operation>
4193 </wsdl:binding>
4194
4195 <wsdl:service name="MOBY__SERVICE__NAME__Service">
4196 <wsdl:documentation><!-- MOBY__SERVICE__DESCRIPTION --></wsdl:documentation> <!-- service description goes here -->
4197 <wsdl:port name="MOBY__SERVICE__NAME__Port" binding="tns:MOBY__SERVICE__NAME__Binding">
4198 <wsdlsoap:address location="MOBY__SERVICE__URL"/> <!-- URL to service scriptname -->
4199 </wsdl:port>
4200 </wsdl:service>
4201  
4202 </wsdl:definitions>
4203  
4204  
4205 END
4206  
4207  
4208 # MOBY CGI service template
4209  
4210 $WSDL_POST_TEMPLATE = <<END2;
4211 <?xml version="1.0"?>
4212 <wsdl:definitions name="MOBY_Central_Generated_WSDL"
4213 targetNamespace="http://biomoby.org/Central.wsdl"
4214 xmlns:tns="http://biomoby.org/Central.wsdl"
4215 xmlns:xsd1="http://biomoby.org/CentralXSDs.xsd"
4216 xmlns:xsd="http://www.w3.org/1999/XMLSchema"
4217 xmlns="http://schemas.xmlsoap.org/wsdl/"
4218 xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
4219 xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
4220 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
4221  
4222
4223 <wsdl:message name="MOBY__SERVICE__NAME__Input">
4224 <wsdl:part name="data" type="xsd:string"/>
4225 </wsdl:message>
4226
4227 <wsdl:message name="MOBY__SERVICE__NAME__Output">
4228 <wsdl:part name="body" type="xsd:string"/>
4229 </wsdl:message>
4230
4231 <wsdl:portType name="MOBY__SERVICE__NAME__PortType">
4232 <wsdl:operation name="MOBY__SERVICE__NAME">
4233 <wsdl:input message="tns:MOBY__SERVICE__NAME__Input"/>
4234 <wsdl:output message="tns:MOBY__SERVICE__NAME__Output"/>
4235 </wsdl:operation>
4236 </wsdl:portType>
4237
4238 <wsdl:binding name="MOBY__SERVICE__NAME__Binding" type="tns:MOBY__SERVICE__NAME__PortType">
4239 <http:binding verb="POST"/>
4240 <wsdl:operation name="MOBY__SERVICE__NAME"><!-- in essense, this is the name of the subroutine that is called -->
4241 <http:operation location='MOBY__SERVICE__POST'/>
4242 <wsdl:input>
4243 <mime:content type="application/x-www-form-urlencoded"/>
4244 </wsdl:input>
4245 <wsdl:output>
4246 <mime:content type="text/xml"/>
4247 </wsdl:output>
4248 </wsdl:operation>
4249 </wsdl:binding>
4250
4251 <wsdl:service name="MOBY__SERVICE__NAME__Service">
4252 <wsdl:documentation><!-- MOBY__SERVICE__DESCRIPTION --></wsdl:documentation> <!-- service description goes here -->
4253 <wsdl:port name="MOBY__SERVICE__NAME__Port" binding="tns:MOBY__SERVICE__NAME__Binding">
4254 <http:address location="MOBY__SERVICE__URL"/> <!-- URL to service scriptname -->
4255 </wsdl:port>
4256 </wsdl:service>
4257  
4258 </wsdl:definitions>
4259  
4260  
4261 END2
4262  
4263 $WSDL_ASYNC_POST_TEMPLATE =<<END;
4264 <?xml version="1.0"?>
4265 <wsdl:definitions name="MOBY_Central_Generated_WSDL"
4266 targetNamespace="http://biomoby.org/Central.wsdl"
4267 xmlns:tns="http://biomoby.org/Central.wsdl"
4268 xmlns:xsd1="http://biomoby.org/CentralXSDs.xsd"
4269 xmlns:xsd="http://www.w3.org/1999/XMLSchema"
4270 xmlns="http://schemas.xmlsoap.org/wsdl/"
4271 xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
4272 xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
4273 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
4274 xmlns:p="http://www.w3.org/2001/XMLSchema">
4275  
4276  
4277 <wsdl:message name="MOBY__SERVICE__NAME__Input">
4278 <wsdl:part name="data" type="xsd:string" />
4279 </wsdl:message>
4280  
4281 <wsdl:message name="MOBY__SERVICE__NAME__Output">
4282 <wsdl:part name="body" type="xsd:string" />
4283 </wsdl:message>
4284  
4285 <wsdl:portType name="MOBY__SERVICE__NAME__PortType">
4286 <wsdl:operation name="MOBY__SERVICE__NAME">
4287 <wsdl:input message="tns:MOBY__SERVICE__NAME__Input" />
4288 <wsdl:output message="tns:MOBY__SERVICE__NAME__Output" />
4289 </wsdl:operation>
4290 </wsdl:portType>
4291 <!-- submit -->
4292 <wsdl:service name="MOBY__SERVICE__NAME__Service">
4293 <wsdl:documentation><!-- MOBY__SERVICE__DESCRIPTION --></wsdl:documentation>
4294 <!-- service description goes here -->
4295 <wsdl:port name="MOBY__SERVICE__NAME__Port"
4296 binding="tns:MOBY__SERVICE__NAME__Binding">
4297 <http:address location="MOBY__SERVICE__URL" />
4298 <!-- URL to service scriptname -->
4299 </wsdl:port>
4300 </wsdl:service>
4301 <wsdl:binding name="MOBY__SERVICE__NAME__Binding"
4302 type="tns:MOBY__SERVICE__NAME__PortType">
4303 <http:binding verb="POST" />
4304 <wsdl:operation name="MOBY__SERVICE__NAME"><!-- in essense, this is the name of the subroutine that is called -->
4305 <http:operation location='MOBY__SERVICE__POST' />
4306 <wsdl:input>
4307 <mime:content part="MOBY__SERVICE__NAME__Input"
4308 type="application/x-www-form-urlencoded" />
4309 </wsdl:input>
4310 <wsdl:output>
4311 <mime:content part="MOBY__SERVICE__NAME__Output"
4312 type="text/xml" />
4313 </wsdl:output>
4314 </wsdl:operation>
4315 </wsdl:binding>
4316  
4317 <!-- results -->
4318 <wsdl:service name="MOBY__SERVICE__NAME__Service_results">
4319 <wsdl:documentation><!-- MOBY__SERVICE__DESCRIPTION --></wsdl:documentation>
4320 <!-- service description goes here -->
4321 <wsdl:port name="MOBY__SERVICE__NAME__Port_results"
4322 binding="tns:MOBY__SERVICE__NAME__Binding_results">
4323 <http:address location="MOBY__SERVICE__URL" />
4324 <!-- URL to service scriptname -->
4325 </wsdl:port>
4326 </wsdl:service>
4327 <wsdl:binding name="MOBY__SERVICE__NAME__Binding_results"
4328 type="tns:MOBY__SERVICE__NAME__PortType">
4329 <http:binding verb="POST" />
4330 <wsdl:operation name="MOBY__SERVICE__NAME"><!-- in essense, this is the name of the subroutine that is called -->
4331 <http:operation location='MOBY__SERVICE__POST' />
4332 <wsdl:input>
4333 <mime:content part="MOBY__SERVICE__NAME__Input"
4334 type="application/x-www-form-urlencoded" />
4335 </wsdl:input>
4336 <wsdl:output>
4337 <mime:content part="MOBY__SERVICE__NAME__Output"
4338 type="text/xml" />
4339 </wsdl:output>
4340 </wsdl:operation>
4341 </wsdl:binding>
4342
4343
4344 <!-- status -->
4345 <wsdl:service name="MOBY__SERVICE__NAME__Service_status">
4346 <wsdl:documentation><!-- MOBY__SERVICE__DESCRIPTION --></wsdl:documentation>
4347 <!-- service description goes here -->
4348 <wsdl:port name="MOBY__SERVICE__NAME__Port_status"
4349 binding="tns:MOBY__SERVICE__NAME__Binding_status">
4350 <http:address location="MOBY__SERVICE__URL" />
4351 <!-- URL to service scriptname -->
4352 </wsdl:port>
4353 </wsdl:service>
4354 <wsdl:binding name="MOBY__SERVICE__NAME__Binding_status"
4355 type="tns:MOBY__SERVICE__NAME__PortType">
4356 <http:binding verb="POST" />
4357 <wsdl:operation name="MOBY__SERVICE__NAME"><!-- in essense, this is the name of the subroutine that is called -->
4358 <http:operation location='MOBY__SERVICE__POST' />
4359 <wsdl:input>
4360 <mime:content part="MOBY__SERVICE__NAME__Input"
4361 type="application/x-www-form-urlencoded" />
4362 </wsdl:input>
4363 <wsdl:output>
4364 <mime:content part="MOBY__SERVICE__NAME__Output"
4365 type="text/xml" />
4366 </wsdl:output>
4367 </wsdl:operation>
4368 </wsdl:binding>
4369 <!-- destroy -->
4370 <wsdl:service name="MOBY__SERVICE__NAME__Service_destroy">
4371 <wsdl:documentation><!-- MOBY__SERVICE__DESCRIPTION --></wsdl:documentation>
4372 <!-- service description goes here -->
4373 <wsdl:port name="MOBY__SERVICE__NAME__Port_destroy"
4374 binding="tns:MOBY__SERVICE__NAME__Binding_destroy">
4375 <http:address location="MOBY__SERVICE__URL" />
4376 <!-- URL to service scriptname -->
4377 </wsdl:port>
4378 </wsdl:service>
4379 <wsdl:binding name="MOBY__SERVICE__NAME__Binding_destroy"
4380 type="tns:MOBY__SERVICE__NAME__PortType">
4381 <http:binding verb="POST" />
4382 <wsdl:operation name="MOBY__SERVICE__NAME"><!-- in essense, this is the name of the subroutine that is called -->
4383 <http:operation location='MOBY__SERVICE__POST' />
4384 <wsdl:input>
4385 <mime:content part="MOBY__SERVICE__NAME__Input"
4386 type="application/x-www-form-urlencoded" />
4387 </wsdl:input>
4388 <wsdl:output>
4389 <mime:content part="MOBY__SERVICE__NAME__Output"
4390 type="text/xml" />
4391 </wsdl:output>
4392 </wsdl:operation>
4393 </wsdl:binding>
4394 </wsdl:definitions>
4395 END
4396  
4397 # for MOBY Asynchronous services. This WSDL is not correct YET!
4398  
4399 $WSDL_ASYNC_TEMPLATE = <<END;
4400 <?xml version="1.0" encoding="UTF-8"?>
4401 <wsdl:definitions name="MOBY_Central_Generated_WSDL" targetNamespace="http://biomoby.org/Central.wsdl"
4402 xmlns:tns="http://biomoby.org/Central.wsdl"
4403 xmlns:xsd1="http://biomoby.org/CentralXSDs.xsd"
4404 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
4405 xmlns:wsoap="http://schemas.xmlsoap.org/soap/envelope/"
4406 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4407 xmlns="http://schemas.xmlsoap.org/wsdl/"
4408 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
4409 xmlns:wsrp="http://docs.oasis-open.org/wsrf/rp-2"
4410 xmlns:wsrl="http://docs.oasis-open.org/wsrf/rl-2"
4411 xmlns:wsbf="http://docs.oasis-open.org/wsrf/bf-2"
4412 xmlns:wsrpw="http://docs.oasis-open.org/wsrf/rpw-2"
4413 xmlns:wsrlw="http://docs.oasis-open.org/wsrf/rlw-2"
4414 xmlns:wsrw="http://docs.oasis-open.org/wsrf/rw-2"
4415 xmlns:wsa="http://www.w3.org/2005/08/addressing">
4416  
4417 <wsdl:import
4418 namespace="http://docs.oasis-open.org/wsrf/rpw-2"
4419 location="http://docs.oasis-open.org/wsrf/rpw-2.wsdl"/>
4420 <wsdl:import
4421 namespace="http://docs.oasis-open.org/wsrf/rlw-2"
4422 location="http://docs.oasis-open.org/wsrf/rlw-2.wsdl"/>
4423 <wsdl:import
4424 namespace="http://docs.oasis-open.org/wsrf/rw-2"
4425 location="http://docs.oasis-open.org/wsrf/rw-2.wsdl"/>
4426 <wsdl:types>
4427 <xsd:schema elementFormDefault="qualified"
4428 targetNamespace="http://biomoby.org/Central.wsdl"
4429 xmlns="http://biomoby.org/Central.wsdl"
4430 >
4431 <xsd:import
4432 namespace="http://docs.oasis-open.org/wsrf/bf-2"
4433 schemaLocation="http://docs.oasis-open.org/wsrf/bf-2.xsd"/>
4434 <xsd:import
4435 namespace="http://docs.oasis-open.org/wsrf/rl-2"
4436 schemaLocation="http://docs.oasis-open.org/wsrf/rl-2.xsd"/>
4437 <xsd:import
4438 namespace="http://www.w3.org/2005/08/addressing"
4439 schemaLocation="http://www.w3.org/2002/ws/addr/ns/ws-addr" />
4440 <xsd:complexType name="MOBY_async_OutputType">
4441 <xsd:sequence minOccurs="1" maxOccurs="1">
4442 <xsd:element ref="wsa:EndpointReference"/>
4443 </xsd:sequence>
4444 </xsd:complexType>
4445
4446 <xsd:element name="ResourceProperties">
4447 <xsd:complexType>
4448 <xsd:sequence>
4449 <xsd:any minOccurs="0" maxOccurs="unbounded"/>
4450 </xsd:sequence>
4451 </xsd:complexType>
4452 </xsd:element>
4453 </xsd:schema>
4454 </wsdl:types>
4455 <wsdl:message name="MOBY__SERVICE__NAME__Input">
4456 <wsdl:part name="data" type="xsd:string"/>
4457 </wsdl:message>
4458 <wsdl:message name="MOBY__SERVICE__NAME__Output">
4459 <wsdl:part name="body" type="xsd:string"/>
4460 </wsdl:message>
4461 <wsdl:message name="MOBY__SERVICE__NAME___submitInput">
4462 <wsdl:part name="data" type="xsd:string"/>
4463 </wsdl:message>
4464 <wsdl:message name="MOBY__SERVICE__NAME___submitOutput">
4465 <wsdl:part name="body" type="tns:MOBY_async_OutputType"/>
4466 </wsdl:message>
4467 <wsdl:portType name="MOBY__SERVICE__NAME__PortType" wsrp:ResourceProperties="tns:ResourceProperties">
4468 <wsdl:operation name="MOBY__SERVICE__NAME__">
4469 <wsdl:input message="tns:MOBY__SERVICE__NAME__Input"/>
4470 <wsdl:output message="tns:MOBY__SERVICE__NAME__Output"/>
4471 </wsdl:operation>
4472 <wsdl:operation name="MOBY__SERVICE__NAME___submit">
4473 <wsdl:input message="tns:MOBY__SERVICE__NAME___submitInput"/>
4474 <wsdl:output message="tns:MOBY__SERVICE__NAME___submitOutput"/>
4475 </wsdl:operation>
4476 </wsdl:portType>
4477 <wsdl:portType name="WSRF_Operations_PortType" wsrp:ResourceProperties="tns:ResourceProperties">
4478 <wsdl:operation name="GetResourceProperty">
4479 <wsdl:input name="GetResourcePropertyRequest" message="wsrpw:GetResourcePropertyRequest"/>
4480 <wsdl:output name="GetResourcePropertyResponse" message="wsrpw:GetResourcePropertyResponse"/>
4481 <wsdl:fault name="ResourceUnknownFault" message="wsrw:ResourceUnknownFault"/>
4482 <wsdl:fault name="ResourceUnavailableFault" message="wsrw:ResourceUnavailableFault"/>
4483 <wsdl:fault name="InvalidResourcePropertyQNameFault"
4484 message="wsrpw:InvalidResourcePropertyQNameFault"/>
4485 </wsdl:operation>
4486 <wsdl:operation name="GetMultipleResourceProperties">
4487 <wsdl:input name="GetMultipleResourcePropertiesRequest"
4488 message="wsrpw:GetMultipleResourcePropertiesRequest"/>
4489 <wsdl:output name="GetMultipleResourcePropertiesResponse"
4490 message="wsrpw:GetMultipleResourcePropertiesResponse"/>
4491 <wsdl:fault name="ResourceUnknownFault" message="wsrw:ResourceUnknownFault"/>
4492 <wsdl:fault name="ResourceUnavailableFault" message="wsrw:ResourceUnavailableFault"/>
4493 <wsdl:fault name="InvalidResourcePropertyQNameFault"
4494 message="wsrpw:InvalidResourcePropertyQNameFault"/>
4495 </wsdl:operation>
4496 <wsdl:operation name="Destroy">
4497 <wsdl:input message="wsrlw:DestroyRequest"/>
4498 <wsdl:output message="wsrlw:DestroyResponse"/>
4499 <wsdl:fault name="ResourceUnknownFault" message="wsrw:ResourceUnknownFault"/>
4500 <wsdl:fault name="ResourceUnavailableFault" message="wsrw:ResourceUnavailableFault"/>
4501 <wsdl:fault name="ResourceNotDestroyedFault" message="wsrlw:ResourceNotDestroyedFault"/>
4502 </wsdl:operation>
4503 </wsdl:portType>
4504 <wsdl:binding name="MOBY__SERVICE__NAME__Binding" type="tns:MOBY__SERVICE__NAME__PortType">
4505 <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
4506 <wsdl:operation name="MOBY__SERVICE__NAME__">
4507 <soap:operation soapAction="http://biomoby.org/#MOBY__SERVICE__NAME__" style="rpc"/>
4508 <wsdl:input>
4509 <soap:body use="encoded" namespace="http://biomoby.org/"
4510 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
4511 </wsdl:input>
4512 <wsdl:output>
4513 <soap:body use="encoded" namespace="http://biomoby.org/"
4514 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
4515 </wsdl:output>
4516 </wsdl:operation>
4517 <wsdl:operation name="MOBY__SERVICE__NAME___submit">
4518 <soap:operation soapAction="http://biomoby.org/#MOBY__SERVICE__NAME___submit" style="rpc"/>
4519 <wsdl:input>
4520 <soap:body use="encoded" namespace="http://biomoby.org/"
4521 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
4522 </wsdl:input>
4523 <wsdl:output>
4524 <soap:body use="encoded" namespace="http://biomoby.org/"
4525 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
4526 </wsdl:output>
4527 </wsdl:operation>
4528 </wsdl:binding>
4529 <wsdl:binding name="WSRF_Operations_Binding" type="tns:WSRF_Operations_PortType">
4530 <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
4531 <wsdl:operation name="GetResourceProperty">
4532 <soap:operation soapAction="http://docs.oasis-open.org/wsrf/rpw-2/GetResourceProperty/GetResourcePropertyRequest" />
4533 <wsdl:input>
4534 <soap:body use="literal"/>
4535 </wsdl:input>
4536 <wsdl:output>
4537 <soap:body use="literal"/>
4538 </wsdl:output>
4539 <wsdl:fault name="ResourceUnknownFault">
4540 <soap:fault name="ResourceUnknownFault" use="literal"/>
4541 </wsdl:fault>
4542 <wsdl:fault name="ResourceUnavailableFault">
4543 <soap:fault name="ResourceUnavailableFault" use="literal"/>
4544 </wsdl:fault>
4545 <wsdl:fault name="InvalidResourcePropertyQNameFault">
4546 <soap:fault name="InvalidResourcePropertyQNameFault" use="literal"/>
4547 </wsdl:fault>
4548 </wsdl:operation>
4549 <wsdl:operation name="GetMultipleResourceProperties">
4550 <soap:operation soapAction="http://docs.oasis-open.org/wsrf/rpw-2/GetMultipleResourceProperties/GetMultipleResourcePropertiesRequest" />
4551 <wsdl:input>
4552 <soap:body use="literal"/>
4553 </wsdl:input>
4554 <wsdl:output>
4555 <soap:body use="literal"/>
4556 </wsdl:output>
4557 <wsdl:fault name="ResourceUnknownFault">
4558 <soap:fault name="ResourceUnknownFault" use="literal"/>
4559 </wsdl:fault>
4560 <wsdl:fault name="ResourceUnavailableFault">
4561 <soap:fault name="ResourceUnavailableFault" use="literal"/>
4562 </wsdl:fault>
4563 <wsdl:fault name="InvalidResourcePropertyQNameFault">
4564 <soap:fault name="InvalidResourcePropertyQNameFault" use="literal"/>
4565 </wsdl:fault>
4566 </wsdl:operation>
4567 <wsdl:operation name="Destroy">
4568 <soap:operation soapAction="http://docs.oasis-open.org/wsrf/rlw-2/ImmediateResourceTermination/DestroyRequest" />
4569 <wsdl:input>
4570 <soap:body use="literal"/>
4571 </wsdl:input>
4572 <wsdl:output>
4573 <soap:body use="literal"/>
4574 </wsdl:output>
4575 <wsdl:fault name="ResourceUnknownFault">
4576 <soap:fault name="ResourceUnknownFault" use="literal"/>
4577 </wsdl:fault>
4578 <wsdl:fault name="ResourceUnavailableFault">
4579 <soap:fault name="ResourceUnavailableFault" use="literal"/>
4580 </wsdl:fault>
4581 <wsdl:fault name="ResourceNotDestroyedFault">
4582 <soap:fault name="ResourceNotDestroyedFault" use="literal"/>
4583 </wsdl:fault>
4584 </wsdl:operation>
4585 </wsdl:binding>
4586 <wsdl:service name="MOBY__SERVICE__NAME__Service">
4587 <wsdl:documentation><!-- MOBY__SERVICE__DESCRIPTION --></wsdl:documentation>
4588 <wsdl:port name="MOBY__SERVICE__NAME__Port" binding="tns:MOBY__SERVICE__NAME__Binding">
4589 <soap:address location="MOBY__SERVICE__URL"/>
4590 </wsdl:port>
4591 <wsdl:port name="WSRF_Operations_Port" binding="tns:WSRF_Operations_Binding">
4592 <soap:address location="MOBY__SERVICE__URL"/>
4593 </wsdl:port>
4594 </wsdl:service>
4595 </wsdl:definitions>
4596  
4597 END
4598  
4599  
4600  
4601  
4602 1;
4603  
« blib/lib/MOBY/MobyXMLConstants.pm ↑ Summary blib/lib/MOBY/OntologyServer.pm »