Bio::DB::Biblio
soap
Toolbar
Summary
Bio::DB::Biblio::soap - A SOAP-based access to a bibliographic query service
Package variables
Privates (from "my" definitions)
$res = shift
$msg = ref $res ? "--- SOAP FAULT ---\n" . $res->faultcode . " " . $res->faultstring : "--- TRANSPORT ERROR ---\n" . $soap->transport->status
Included modules
SOAP::Lite on_fault => sub { my $soap = shift
Inherit
Synopsis
Do not use this object directly, it is recommended to access it and use
it through the
Bio::Biblio module:
use Bio::Biblio;
my $biblio = new Bio::Biblio (-access => 'soap');
Description
This object contains the real implementation of a Bibliographic Query
Service as defined in
Bio::DB::BiblioI - using a SOAP protocol
to access a WebService (a remote server) that represents a
bibliographic repository.
Methods
BEGIN | | Code |
DESTROY | No description | Code |
_as_strings | No description | Code |
_initialize | Description | Code |
_missing_name_msg | No description | Code |
_no_id_msg | No description | Code |
_old_version_msg | No description | Code |
_two_params_msg | No description | Code |
contains | No description | Code |
destroy | No description | Code |
exists | No description | Code |
find | No description | Code |
get_all | No description | Code |
get_all_entries | No description | Code |
get_all_ids | No description | Code |
get_all_values | No description | Code |
get_by_id | No description | Code |
get_collection_id | No description | Code |
get_count | No description | Code |
get_entry_description | No description | Code |
get_more | No description | Code |
get_next | No description | Code |
get_vocabulary_names | No description | Code |
has_next | No description | Code |
reset_retrieval | No description | Code |
Methods description
Usage : my $obj = new Bio::Biblio (-access => 'soap' ...); (_initialize is internally called from this constructor) Returns : nothing interesting Args : This module recognises and uses following arguments:
-namespace => 'urn'
The namespace used by the WebService that is being
accessed. It is a string which guarantees its world-wide
uniqueness - therefore it often has a style of a URL -
but it does not mean that such pseudo-URL really exists.
Default is 'http://industry.ebi.ac.uk/openBQS' (which well corresponds with the default '-location' - see module Bio::Biblio).
-destroy_on_exit => '0'
Default value is '1' which means that all Bio::Biblio
objects - when being finalised - will send a request
to the remote WebService to forget the query collections
they represent.
If you change it to '0' make sure that you know the
query collection identification - otherwise you will
not be able to re-established connection with it.
This can be done by calling method get_collection_id.
-collection_id => '...'
It defines what query collection will this object work
with. Use this argument when you know a collection ID
of an existing query collection and when you wish to
re-established connection with it.
By default, the collection IDs are set automatically
by the query methods - they return Bio::Biblio objects
already having a collection ID.
A missing or undefined collection ID means that the
object represents the whole bibliographic repository
(which again means that some methods, like get_all,
will be probably refused).
-soap => a SOAP::Lite object
Usually all Bio::Biblio objects share an instance of
the underlying SOAP::Lite module. But you are free
to have more - perhaps with different characteristics.
See the code for attributes of the default SOAP::Lite
object.
-httpproxy => 'http://server:port' In addition to the 'location' parameter, you may need to specify also a location/URL of a HTTP proxy server (if your site requires one).
Additionally, the main module Bio::Biblio recognises
also:
-access => '...'
-location => '...'
It populates calling object with the given arguments, and then - for some attributes and only if they are not yet populated - it assigns some default values. This is an actual new() method (except for the real object creation and its blessing which is done in the parent class Bio::Root::Root in method _create_object). Note that this method is called always as an object method (never as a class method) - and that the object who calls this method may already be partly initiated (from Bio::Biblio::new method); so if you need to do some tricks with the 'class invocation' you need to change Bio::Biblio::new method, not this one. |
Methods code
BEGIN { $VERSION = do { my @r = (q$$Revision: 1.5 $ =~ /\d+/g); sprintf "%d.%-02d", @r };
$Revision = q$$Id: soap.pm,v 1.5 2002/10/22 07:45:14 lapp Exp $;
$DEFAULT_SERVICE = 'http://industry.ebi.ac.uk/soap/openBQS';
$DEFAULT_NAMESPACE = 'http://industry.ebi.ac.uk/openBQS'; } |
sub DESTROY
{ my $self = shift;
my $soap = $self->{'_soap'};
my $destroy = $self->{'_destroy_on_exit'};
return unless $destroy;
my $collection_id = $self->{'_collection_id'};
return unless $collection_id;
eval {
$soap->destroy (SOAP::Data->type (string => $collection_id));
}
}
} |
sub _as_strings
{ my ($ref_input_array) = @_;
my (@result) = map { SOAP::Data->new (type => 'string', value => $_) } @$ref_input_array;
return\@ result;
}
} |
sub _initialize
{ my ($self, @args) = @_;
my %param = @args;
@param { map { lc $_ } keys %param } = values %param;
my $new_key;
foreach my $key (keys %param) {
($new_key = $key) =~ s/^-/_/;
$self->{ $new_key } = $param { $key };
}
$self->{'_location'} = $DEFAULT_SERVICE unless $self->{'_location'};
$self->{'_namespace'} = $DEFAULT_NAMESPACE unless $self->{'_namespace'};
$self->{'_destroy_on_exit'} = 1 unless defined $self->{'_destroy_on_exit'};
unless ($self->{'_soap'}) {
if (defined $self->{'_httpproxy'}) {
$self->{'_soap'} = SOAP::Lite
-> uri ($self->{'_namespace'})
-> proxy ($self->{'_location'},
proxy => ['http' => $self->{'_httpproxy'}]);
} else {
$self->{'_soap'} = SOAP::Lite
-> uri ($self->{'_namespace'})
-> proxy ($self->{'_location'});
}
}
}
} |
sub _missing_name_msg
{ my $self = shift;
my $method = (caller(1))[3];
return <<"END_OF_MSG"; Method '$method' expects vocabulary name as parameter. END_OF_MSG }
} |
sub _no_id_msg
{ my $self = shift;
my $package = ref $self;
my $method = (caller(1))[3];
my $strip_method = $method;
$strip_method =~ s/^$package\:\://;
return <<"END_OF_MSG"; Method '$method' works only if its object has a query collection ID. Perhaps you need to use: \tnew Bio::Biblio (-collection_id => '1234567')->$strip_method; or to obtain a collection ID indirectly from a query method: \tnew Bio::Biblio->find ('keyword')->$strip_method; END_OF_MSG }
} |
sub _old_version_msg
{ my $self = shift;
my $method = (caller(1))[3];
return <<"END_OF_MSG"; Method '$method' works only with SOAP::Lite version 0.52 and newer (the problem is with returning a boolean value from the server). END_OF_MSG }
} |
sub _two_params_msg
{ my $self = shift;
my $method = (caller(1))[3];
return <<"END_OF_MSG"; Method '$method' expects two parameters: vocabulary name and a value. END_OF_MSG }
} |
sub contains
{ my ($self, $vocabulary_name, $value) = @_;
my $soap = $self->{'_soap'};
$self->throw ($self->_old_version_msg) if $SOAP::Lite::VERSION < 0.52;
$self->throw ($self->_two_params_msg)
unless defined $vocabulary_name and defined $value;
$soap->contains (SOAP::Data->type (string => $vocabulary_name),
SOAP::Data->type (string => $value))->result; } |
sub destroy
{ my ($self) = @_;
my $soap = $self->{'_soap'};
my ($collection_id) = $self->{'_collection_id'};
$self->throw ($self->_no_id_msg) unless $collection_id;
$soap->destroy (SOAP::Data->type (string => $collection_id)); } |
sub exists
{ my ($self) = @_;
my $soap = $self->{'_soap'};
my ($collection_id) = $self->{'_collection_id'};
$self->throw ($self->_no_id_msg) unless $collection_id;
$self->throw ($self->_old_version_msg) if $SOAP::Lite::VERSION < 0.52;
$soap->exists (SOAP::Data->type (string => $collection_id))->result; } |
sub find
{ my ($self, $keywords, $attrs) = @_;
my (@keywords, @attrs);
if ($keywords) {
my $ref = ref $keywords;
@keywords = split (/,/, $keywords) unless $ref;
@keywords = @$keywords if $ref =~ /ARRAY/;
}
$self->throw ("No keywords given in 'find' method.\n")
unless (@keywords);
if ($attrs) {
my $ref = ref $attrs;
@attrs = split (/,/, $attrs) unless $ref;
@attrs = @$attrs if $ref =~ /ARRAY/;
}
my $soap = $self->{'_soap'};
my $collection_id = $self->{'_collection_id'};
my $new_id;
if ($collection_id) {
if (@attrs) {
$new_id = $soap->find (SOAP::Data->type (string => $collection_id),
&_as_strings (\@keywords),
&_as_strings (\@attrs))->result;
} else {
$new_id = $soap->find (SOAP::Data->type (string => $collection_id),
&_as_strings (\@keywords))->result;
}
} else {
if (@attrs) {
$new_id = $soap->find (&_as_strings (\@keywords),
&_as_strings (\@attrs))->result;
} else {
$new_id = $soap->find (&_as_strings (\@keywords))->result;
}
}
return $self->new (-collection_id => $new_id,
-parent_collection_d => $collection_id); } |
sub get_all
{ my ($self) = @_;
my $soap = $self->{'_soap'};
my ($collection_id) = $self->{'_collection_id'};
$self->throw ($self->_no_id_msg) unless $collection_id;
$soap->getAllBibRefs (SOAP::Data->type (string => $collection_id))->result; } |
sub get_all_entries
{ my ($self, $vocabulary_name) = @_;
my $soap = $self->{'_soap'};
$self->throw ($self->_missing_name_msg)
unless defined $vocabulary_name;
$soap->getAllEntries (SOAP::Data->type (string => $vocabulary_name))->result; } |
sub get_all_ids
{ my ($self) = @_;
my $soap = $self->{'_soap'};
my ($collection_id) = $self->{'_collection_id'};
$self->throw ($self->_no_id_msg) unless $collection_id;
$soap->getAllIDs (SOAP::Data->type (string => $collection_id))->result; } |
sub get_all_values
{ my ($self, $vocabulary_name) = @_;
my $soap = $self->{'_soap'};
$self->throw ($self->_missing_name_msg)
unless defined $vocabulary_name;
$soap->getAllValues (SOAP::Data->type (string => $vocabulary_name))->result; } |
sub get_by_id
{ my ($self, $citation_id) = @_;
$self->throw ("Citation ID is expected as a parameter of method 'get_by_id'.")
unless $citation_id;
my $soap = $self->{'_soap'};
$soap->getById (SOAP::Data->type (string => $citation_id))->result; } |
sub get_collection_id
{ my ($self) = @_;
$self->{'_collection_id'}; } |
sub get_count
{ my ($self) = @_;
my $soap = $self->{'_soap'};
my ($collection_id) = $self->{'_collection_id'};
if ($collection_id) {
$soap->getBibRefCount (SOAP::Data->type (string => $collection_id))->result;
} else {
$soap->getBibRefCount->result;
}
}
} |
sub get_entry_description
{ my ($self, $vocabulary_name, $value) = @_;
my $soap = $self->{'_soap'};
$self->throw ($self->_two_params_msg)
unless defined $vocabulary_name and defined $value;
$soap->getEntryDescription (SOAP::Data->type (string => $vocabulary_name),
SOAP::Data->type (string => $value))->result; } |
sub get_more
{ my ($self, $how_many) = @_;
my $soap = $self->{'_soap'};
my $collection_id = $self->{'_collection_id'};
$self->throw ($self->_no_id_msg) unless $collection_id;
unless (defined ($how_many) and $how_many =~ /^\d+$/) {
warn ("Method 'get_more' expects a numeric argument. Changing to 1.\n");
$how_many = 1;
}
unless ($how_many > 0) {
warn ("Method 'get_more' expects a positive argument. Changing to 1.\n");
$how_many = 1;
}
my $ra = $soap->getMore (SOAP::Data->type (string => $collection_id),
SOAP::Data->type (int => $how_many))->result;
$self->{'_collection_id'} = shift @{ $ra };
$ra; } |
sub get_next
{ my ($self) = @_;
my $soap = $self->{'_soap'};
my ($collection_id) = $self->{'_collection_id'};
$self->throw ($self->_no_id_msg) unless $collection_id;
my $ra = $soap->getNext (SOAP::Data->type (string => $collection_id))->result;
$self->{'_collection_id'} = shift @{ $ra };
shift @{ $ra }; } |
sub get_vocabulary_names
{ my ($self) = @_;
my $soap = $self->{'_soap'};
$soap->getAllVocabularyNames->result; } |
sub has_next
{ my ($self) = @_;
my $soap = $self->{'_soap'};
my ($collection_id) = $self->{'_collection_id'};
$self->throw ($self->_no_id_msg) unless $collection_id;
$self->throw ($self->_old_version_msg) if $SOAP::Lite::VERSION < 0.52;
$soap->hasNext (SOAP::Data->type (string => $collection_id))->result; } |
reset_retrieval | description | prev | next | Top |
sub reset_retrieval
{ my ($self) = @_;
my $soap = $self->{'_soap'};
my ($collection_id) = $self->{'_collection_id'};
$self->throw ($self->_no_id_msg) unless $collection_id;
$self->{'_collection_id'} = $soap->resetRetrieval (SOAP::Data->type (string => $collection_id))->result; } |
General documentation
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/MailList.shtml - About the mailing lists
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
email or the web:
bioperl-bugs@bioperl.org
http://bugzilla.bioperl.org/
Copyright (c) 2002 European Bioinformatics Institute. All Rights Reserved.
This module is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
This software is provided "as is" without warranty of any kind.
*(1)
Methods returning a boolean value (
has_next,
exists and
contains) can be used only with SOAP::Lite version 0.52 and newer
(probably due to a bug in the older SOAP::Lite).
*(2)
It does not use WSDL. Coming soon...
*(3)
There is an open question to discuss: should the service return
citations as type
string or rather as type
base64? What is
faster? What is better for keeping non-ASCII characters untouched? How
the decision would be influenced if the transparent compression
support is introduced?
*(4)
More testing and debugging needed to ensure that returned citations
are properly transferred even if they contain foreign characters.
The main documentation details are to be found in
Bio::DB::BiblioI.
Here is the rest of the object methods. Internal methods are preceded
with an underscore _.
Usage : print $Bio::DB::Biblio::soap::VERSION;
print $Bio::DB::Biblio::soap::Revision;
Usage : print $Bio::DB::Biblio::soap::DEFAULT_SERVICE;
print $Bio::DB::Biblio::soap::DEFAULT_NAMESPACE;