Discovering your service

To discover a service (for example, the service "getGoTerm" that you just registered in Registering Your Service if you are following through the full tutorial) you could use a wide variety of different searches. The most precise search is to search by service name and authority URI, since these two elements uniquely identify any BioMoby service. To do a precise search, simply:

use MOBY::Client::Central;

my $m = MOBY::Client::Central->new;
my ($serv_instances, $reg) = $m->findService(
    authURI => "mydomain.mycompany.org",
    serviceName => "getGoTerm");

print "Found ", (scalar @$serv_instances), " match to your query.";

my $SI = shift @$serv_instances; # $SI is a MOBY::Client::ServiceInstance object

print "Service Name: ", $SI->name, "\n";
print "Authority: ", $SI->authority, "\n";
print "Description: ", $SI->description, "\n";

my $inputs = $SI->input;  # listref of MOBY::Client::SimpleArticle
                          # or MOBY::Client::CollectionArticle objects
foreach (@$inputs){
    next unless $_->isSimple;
    print "Simple Input ", $_->articleName, "\n";
    print "\tof Object Type ", $_->objectType, "\n";
    my $namespaces = $_->namespaces;
    foreach my $n(@$namespaces){
	print "\t\tin Namespace $n\n";
    }
}

foreach (@$inputs){
    next unless $_->isCollection;
    print "Collection Input ", $_->articleName, "\n";
    my $simples = $_->Simples
    foreach my $simp(@$simples){	
	print "\tof Object Type ", $simp->objectType, "\n";
	my $namespaces = $simp->namespaces;
	foreach my $n(@$namespaces){
	    print "\t\tin Namespace $n\n";
	}
    }
}
my $secondaries = $SI->secondary;  # listref of MOBY::Client::SecondaryArticle

foreach (@$secondaries){
    next unless $_->isSecondary;  
    print "Secondary Input ", $_->articleName, "\n";
    print "\tof Type ", $_->datatype, "\n";
    print "\tmax ", $_->max, "\n" if $_->max;
    print "\tmin ", $_->min, "\n" if $_->min;
    print "\tdefault ", $_->default, "\n" if $_->default;
    print "\tDescription ", $_->description, "\n" if $_->description;
}

# and you can do the same thing for outputs as you just did for inputs