On the ChEBI Web Services page: https://www.ebi.ac.uk/chebi/webServices.do
They give two examples of SOAP Clients for retrieving data from ChEBI, one of them is written in Java, one of them written in Perl. Heres the Perl example:
#!/usr/bin/perl -w
# SOAP::Lite version 0.67
# Please note: ChEBI webservices uses document/literal binding
use SOAP::Lite + trace => qw(debug);
#use SOAP::Lite;
# Setup service
my $WSDL = 'http://www.ebi.ac.uk/webservices/chebi/2.0/webservice?wsdl';
my $nameSpace = 'http://www.ebi.ac.uk/webservices/chebi';
my $soap = SOAP::Lite
-> uri($nameSpace)
-> proxy($WSDL);
# Setup method and parameters
my $method = SOAP::Data->name('getCompleteEntity')
->attr({xmlns => $nameSpace});
my @params = ( SOAP::Data->name(chebiId => 'CHEBI:15377'));
# Call method
my $som = $soap->call($method => @params);
# Retrieve for example all ChEBI identifiers for the ontology parents
@stuff = $som->valueof('//OntologyParents//chebiId');
print @stuff;
The language I know best is PHP, so I want to convert this example into PHP. I'm new to the whole SOAP thing, so I barely know where to start. Heres what I started with:
$WSDL = 'http://www.ebi.ac.uk/webservices/chebi/2.0/webservice?wsdl';
$nameSpace = 'http://www.ebi.ac.uk/webservices/chebi';
$options = array(
'uri'=>$nameSpace,
'trace'=>true,
'encoding'=>'UTF-8',
'exceptions'=>true,
);
/* Initialize webservice with your WSDL */
$client = new SoapClient($WSDL,$options);
/* Set your parameters for the request */
$params = array(
'chebiId' => 'CHEBI:15377',
);
/* Invoke webservice method with your parameters */
$response = $client->__soapCall("getCompleteEntity", array($params));
/* Print webservice response */
var_dump($response);
Heres the output of that: http://pastebin.com/g3w0wf6u
So the things I'm wondering are:
1.) What do I do with the namespace? In the perl example, they setup the service like this:
my $soap = SOAP::Lite
-> uri($nameSpace)
-> proxy($WSDL);
How do I use the namespace with PHP SoapClient? I added it as the 'uri' option when setting up the webservice, but I don't actually know what that means. And they setup the method like this:
# Setup method and parameters
my $method = SOAP::Data->name('getCompleteEntity')
->attr({xmlns => $nameSpace});
I see I need to apply it to the methods also. How do I setup a new method with the namespace applied, as shown in the Perl example?
What does proxy and uri mean in the perl example?
Also how can I replicate this:
@stuff = $som->valueof('//OntologyParents//chebiId');
With the SoapClient?